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" <[EMAIL PROTECTED]>
>>To: [EMAIL PROTECTED]
>>Subject: [PHP] Re: Active PHP Sessions
>>Date: Fri, 7 May 2004 15:30:29 +0200
>>
>>"Paul Higgins" <[EMAIL PROTECTED]> wrote in message
>>news:[EMAIL PROTECTED]
>> > 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to