Re: PHP SESSION timeouts
| From: | Catalin Trifu | Date: | Sun, 31 Aug 2003 11:38:19 +0000 |
| Subject: | Re: PHP SESSION timeouts | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-161291@lists.php.net to get a copy of this message | ||
Hi,
No, there is not! You have to manage yourself
the timeout, for instance through a timestamp,
which you verify on each request. PHP does not
destry sessions by itself. It's up to you to manage
the "life" of a session.
<snip>
if($_SESSION['last_seen'] && ($_SESSION['last_seen'] < time() -
timeout)
{
//session is ok proceed
} else {
//session expired
$_SESSION = array();//destroy session
//whatever you want to do
}
</snip>
btw! the code above does not take care of the first time
a user visits u'r page.
Cheers,
Catalin
"James Johnson" <james@smb-studios.com> wrote in message
news:001001c36f4e$22500e70$6401a8c0@james...
> Hi,
>
> Can't find this in any of my books. Is there a default for when the
> $_SESSION array times out i.e., it's no longer available for the code?
>
> Thanks,
> James