Entry
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 -
http://www.zend.com/zend/spotlight/code-gallery-wade8.php
There is a class definition you can just copy and use as is.