Posted by Mike Willbanks on 02/18/06 03:33
Micky,
> In regards to creating a timestamp. I'm guessing that php's date()
> function would be used?
> I'm just wondering how to distinguish between the current time & the
> last activity?
Nope do it with time() and give them a timestamp.... Here is an easy
example to use on each page with a session to see if it has expired or not:
if (!isset($_SESSION['last_activity'])) {
$_SESSION['last_activity'] = time();
} elseif((time()-$_SESSION['last_activity'])>600) {
$_SESSION = array();
if (isset($_COOKIE[session_name()])) {
unset($_COOKIE[session_name()]);
}
session_destroy();
} else {
$_SESSION['last_activity'] = time();
}
The 600 means 10 minutes the till it will destroy the session from the
last access. This is by no means a clean example but it should help
just to show you the basics...
--
Mike Willbanks
Zend Certified Engineer
http://blog.digitalstruct.com
[Back to original message]
|