I am developing a php application. Is it possible to get active sessions and session values on my server? And is it possible to end up a particular session?
Asked
Active
Viewed 4,695 times
0
-
possible duplicate of [Access active sessions in PHP](http://stackoverflow.com/questions/3426844/access-active-sessions-in-php) – Wesley van Opdorp Dec 21 '11 at 09:02
-
Does this help: http://stackoverflow.com/questions/675913/looping-through-all-a-servers-sessions-in-php – Dennis Dec 21 '11 at 09:03
2 Answers
5
If you want maximum flexibility with sessions you can save all your sessions in a database. Then it is very easy to get number of sessions, content of any session, kill them, etc...
http://shiflett.org/articles/storing-sessions-in-a-database
As a bonus you will increase the security!

macjohn
- 1,755
- 14
- 18
-
Yah... Will try this. But one a session get expired, database values will still remain as it is right? – Javad Shareef Dec 21 '11 at 09:14
-
There is a handler to a function that is called every once in a while in order to clean out (delete) old records in the session data store. – macjohn Dec 21 '11 at 09:19
1
Currently in PHP you cannot get the active sessions directly. But, you can create your own session handler ( http://pt2.php.net/manual/en/function.session-set-save-handler.php ) and manage the session files.

ocirocir
- 3,543
- 2
- 24
- 34