|
Posted by Rik Wasmus on 01/20/08 12:13
On Sun, 20 Jan 2008 00:03:14 +0100, <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??
Easiest way: define a database storage handler for the session (see
http://php.net/session_set_save_handler), use a table with a datetime or
timestamp field (always updated to the current time on save) and a
blob/text field for the session-data. Define a proper function for the
garbage-collector which uses the settings for a session
(session.gc_maxlifetime), and everything will be done automatically.
Getting information about current sessions now becomes a simple query on
the database.
--
Rik Wasmus
Navigation:
[Reply to this message]
|