Difference between revisions of "Sessions are ending before MaxLifetime"

From Brian Nelson Ramblings
Jump to: navigation, search
(Created page with "==Sessions are ending before MaxLifetime== Have you ever noticed that your shopping cart does not keep products past closing the browser or they empty out while shopping? Th...")
 
(Sessions are ending before MaxLifetime)
 
Line 11: Line 11:
  
 
Setting the session.gc_maxlifetime tells php to remove the session after a specific amount of time.
 
Setting the session.gc_maxlifetime tells php to remove the session after a specific amount of time.
 +
 +
===Check current settings====
 +
 +
You can check your settings by checking your phpinfo() file or running php -i from the command line.
 +
 +
php -i |grep -E 'session.gc_maxlife|session.cookie_life'
 +
 +
session.cookie_lifetime => 0 => 0
 +
session.gc_maxlifetime => 259200 => 259200

Latest revision as of 15:51, 1 April 2014

Sessions are ending before MaxLifetime

Have you ever noticed that your shopping cart does not keep products past closing the browser or they empty out while shopping?

There are two parameters you need to worry about regarding sessions. The first is the TTL for the cookie, the other is how old a session data file can become before it gets garbage collected.

1) session.cookie_lifetime determines, in seconds, how long the cookie sent to the browser will last. It defaults to 0, which means until the browser closes. For two days it'd need to be 172800 seconds. 2) session.gc_maxlifetime determines, also in seconds, how long before session data marked on the server will be regarded as garbage and can be deleted.

Setting the session.cookie_lifetime allows the browser to close and when you go back within the given seconds your products will still be available.

Setting the session.gc_maxlifetime tells php to remove the session after a specific amount of time.

Check current settings=

You can check your settings by checking your phpinfo() file or running php -i from the command line.

php -i |grep -E 'session.gc_maxlife|session.cookie_life'

session.cookie_lifetime => 0 => 0
session.gc_maxlifetime => 259200 => 259200