faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 25 people (52%) answered Yes
Recently 6 of 10 people (60%) answered Yes


is there a way to count the number of currently active sessions?

Feb 11th, 2005 03:55
Stoyan Stefanov, Guest,

Yes, it is possible and not very hard to do.
By default php stores session data in files, but you can override this
behaviour and define your own session handling functions that will store
the session data in a database table. Then all you need to do is
SELECT COUNT(*) FROM `your_session_table`;
... and you'll have the number of active sessions.
Redefining session handlers may sound complicated, but you can find a
nice article on how to do this on zend.com -
There is a class definition you can just copy and use as is.