Reply to Re: Destroy Session on page change

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация