Caveat: similar to, but still different from this thread.
In a home-rolled ecomm app, a session with a param of order_id is created by a Perl module common to all instances when an item is added to the shopping cart:
$self->session_config(
DEFAULT_EXPIRY => '+4h',
COOKIE_PARAMS => {
-name => 'ECOMM_SESSID',
-expires => '+4h',
-path => '/',
-domain => '.mydomain.com',
},
SEND_COOKIE => 1
);
This instance is fired by cart.cgi
which calls Cart.cgi
.
When viewing the cart, a variable dump shows
$self->session->param( 'order_id' )
= 4123`session id = 1111111
*ECOMM_SESSID
cookie in the header†When other items are added to the cart, variable dumps continue to show the same values.
If one clicks "Checkout", shipping.cgi
fires calling Shipping.pm
. The existence of the order_id param is checked in the cgiapp_prerun
part of the module. However, a data dump shows:
$self->session->param( 'order_id' )
= null`session id = 2222222
*ECOMM_SESSID
cookie missing from the header†A new session is being created, losing the order_id param.
Interestingly, if I go back to the cart, all the original values are there.
So, my question: how do I prevent a new session, thus preserving the old and the values needed to proceed in the checkout process?
*simplified †in browser Inspector
Solved my issue. PEBKAC error. The reason is was recreating two sessions with the same name but different ID's is that the shipping module was using a different domain name. So, the introduction of a new domain name was forcing a new session. Backstory: I had set this up as a staging site, but after pushing it live, forgot to adjust the link to shipping. Finally saw it in the URL. Insert head slap