[nycphp-talk] PHP Sessions, Expiration, and all that
Chris Shiflett
shiflett at php.net
Fri May 4 09:23:01 EDT 2007
Hi Paul,
> Our client wants sessions to time out after six hours of
> inactivity, and I'm wondering if there's an easy way to do
> that by configuring PHP.
Yes, but keep in mind that session.gc_maxlifetime indicates a maximum,
not a minimum. PHP isn't going to check on every request to see whether
it should clean up stale sessions; there's some probability involved.
However, you can change that, too. :-)
> $now=time();
> if(isset($_SESSION["timestamp"])) {
> ... dump session if now-timestamp > limit ...
> }
> $_SESSION["timestamp"]=$now;
Seems like a fine way to do it to me.
Chris
--
Chris Shiflett
http://shiflett.org/
More information about the talk
mailing list