Reply to Re: how to automatically logout users from my site

Your name:

Reply:


Posted by Jensen Somers on 01/19/08 23:35

Hello,

camilin87@gmail.com wrote:
> hello.
> I'm building a site using php I have a setup.php page wich has at the
> begining session_start();
> and every single page from my site includes setup.php. When a user
> registers I save in $_SESSION["Login"] the userName, so that when !
> isset($_SESSION["Login"]) I can redirect him to the login.php page.
> After some inactivityperiod, e.g. 20 min, I need that user to be
> automatically logged off. Besides I need to keep track of the users
> that are online in that moment, so the logout should run some server-
> side script too. Can anyone give me some ideas??

I handle things very basic and easily. I have a session class which holds all the
information I need to save in a session (user login details, current shopping
list items...) and one of those is the time when the session was created. When
the user moves to the next page one of the functions I call is one that checks
the current time against the saved session time. If the difference between those
is greater than time X I call the logout function and redirect the user to the
login form.

I don't really see a point in checking the login time of the user with some cron
job. If he wants to leave a page open for 2 hours that's fine, he can't do
anything special with it. If he closes the browser the session is destroyed, if
he moves to another page I have the checking routines.

- Jensen

[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

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