Simon
Simon

Reputation: 5247

PHP $_SESSION Expiry

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.

Upvotes: 0

Views: 952

Answers (1)

Sven Koschnicke
Sven Koschnicke

Reputation: 6711

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.

Upvotes: 2

Related Questions