Page 1 of 1
Cart session duration
Posted: 2017-01-23 18:00
by s3am
Hello Fred
Do you thing it's possible to set a cart session duration, 1 week for example.
Best regards
Adel
Re: Cart session duration
Posted: 2017-01-30 13:56
by Fred
To be honest I haven' t looked at how long the cart session would last normally. I would assume the "standard" 24 minutes as set by your host.
if you have mod_php5.c installed on your server you could try the following in your htaccess file
3600 is the number of seconds, in this case 60 minutes.
Code: Select all
<IfModule mod_php5.c>
#Session timeout
php_value session.cookie_lifetime 3600
php_value session.gc_maxlifetime 3600
</IfModule>
If you not sure about the availability if mod_php5.c on your server you can still add the above to the htaccess file. It just would not work. So nothing to loose.
Re: Cart session duration
Posted: 2017-01-30 14:00
by Fred
You can also try this. Add it to a file that get loaded on every page on your site.
Obviously adjust the seconds to suit.
Code: Select all
// Set max_life
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) {
// last request was more than 30 minutes ago
session_unset(); // unset $_SESSION variable for the run-time
session_destroy(); // destroy session data in storage
}
$_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
// Prevent session fixation
if (!isset($_SESSION['CREATED'])) {
$_SESSION['CREATED'] = time();
} else if (time() - $_SESSION['CREATED'] > 1800) {
// session started more than 30 minutes ago
session_regenerate_id(true); // change session ID for the current session and invalidate old session ID
$_SESSION['CREATED'] = time(); // update creation time
}
// End Set max_life