3

When I store a variable in a session (in php), how long will that variable linger in that file? Will it be there until someone unsets the variable or deletes the file?

update: so it is session.gc-maxlifetime setting that is set in php.ini file. You can check your setting by calling phpinfo(). Mine is set to 1440 seconds so 24 minutes. Might have found a duplicate here, although when googling I didn't find it at first because of the wording.

Community
  • 1
  • 1
dev.e.loper
  • 35,446
  • 76
  • 161
  • 247

2 Answers2

10

By default it will be there 24 minutes. (Which is the default php.ini file setting).

As you commented, this is the setting: http://www.php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime

Rene Pot
  • 24,681
  • 7
  • 68
  • 92
  • Is this the setting you are talking about? http://www.php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime – dev.e.loper Sep 29 '11 at 20:57
  • so 24 minutes is the time it last on server by default. How long session cookie will last on the client? – angry kiwi Aug 05 '12 at 02:07
1

Look in your php.ini file. It will tell you exactly how long the default session will last.

Chris G.
  • 3,963
  • 2
  • 21
  • 40