Re: Re: Active PHP Sessions

From: Date: Fri, 07 May 2004 14:35:32 +0000
Subject: Re: Re: Active PHP Sessions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-185621@lists.php.net to get a copy of this message
Friday, May 7, 2004, 3:40:06 PM, thus was written: > I've read stuff like that also. However, if I choose to do this, I must > write all the session handling myself, correct? Well, yes and no: You could still use the default session handler and just add a function/whatever to the top of the page that updates the database, reads the number of sessions and on occasion makes a garbage collection: You could for eaxmple use a simple table with two columns: session_id, last_access if ( there is a valid session ) update last access of this session_id in the table // if mySQL you could use a REPLACE INTO count number of sessions WHERE last_access < timespan counting as active session // have some basic form of garbage collection if ( rand (1, n) == 1 ) delete from session WHERE last_access > session timeout I think that might work... (at least it's an outline of how I did it.) Two/three (depending on the database) DB queries and on occasion three/four .. not too much overhead, considering you would have to read the whole session directory if you chose to check the files... my 2c Richard >>From: "Torsten Roehr" <roehr@zilleon.com> >>To: php-general@lists.php.net >>Subject: [PHP] Re: Active PHP Sessions >>Date: Fri, 7 May 2004 15:30:29 +0200 >> >>"Paul Higgins" <developer_paul_php@hotmail.com> wrote in message >>news:BAY13-F73ib4g3Sv0YK000050ec@hotmail.com... >> > Hi all, >> > >> > I'm on a shared server, and I do not believe that I have access to the >>/tmp >> > directory where the session files are stored (I believe that is how it >>works >> > :). I want to keep track of which sessions are active. Basically, I >>just >> > want a list of the active sessions for my site. >> > >> > How can I do this? >> >>If you use a database as container for your session data you could easily >>do >>a SELECT COUNT(*) FROM sessions to get the number of the sessions. Using a >>DB as session container is also more secure on a shared server (at least >>that's what I often read about session security). >> >>Regards, Torsten

« previous php.general (#185621) next »