views:

32

answers:

1

Does the $_SESSION expire at any time point? Obviously you can call session_destroy() or close the browser. I just had a application fail because it was relying on the session and the browser had been open for 2 days. I guess the session must have expired.

+2  A: 

Yes it can be configured in the php.ini. See here http://www.php.net/manual/en/function.session-cache-expire.php

I think one way is to set http://www.php.net/manual/en/session.configuration.php#ini.session.cookie-lifetime , but then you rely on the browser to really delete the session cookie when it expires. So it would be best to save the last-seen-time in the session and remove sessions when a maximum time is reached.

Sven Koschnicke
Thanks. That's how long the server cache lives on the server. It has nothing to do with how long it survives in the browser. So unless I create a routine to check for expiry it should last forever in the browser.
Simon