Jump to content

PHP Session Monitoring


Mahdi

Recommended Posts

Hello,

I wanted to know if it is possible to monitor $_SESSION data that is currently active on the server.

I.E.

We set $_SESSION['userID'] when someone logs into their account, we would like to actively monitor the time that this session remains active. So if the user is online for 6 hours, we use a PHP page that pulls this information.

start time = 8:00AM

user1 logs on at 8:15AM
user2 logs on at 8:45AM
user3 logs on at 9:30AM

current time = 10:00AM

user1 is offline, session was active for 45 minutes (logged off at 9:00AM)
user2 is active, and has been on for 1h 15mins
user3 is active, and has been on for 30mins

______________

Kind of a rough idea I know, but I wanted to know if getting this kind of information is even possible with sessions, or cookies for that matter.

Thanks a ton!
Mahdi

Link to comment
https://forums.phpfreaks.com/topic/27169-php-session-monitoring/
Share on other sites

Usually, session data is stored in files.  It may be stored in /tmp , or in some other directory.  There's more information at http://sg.php.net/manual/en/ref.session.php

But I would recommend keeping your own records in a database if possible.  A text file would also be good enough.  Keep in mind that if someone just closes the browser without logging out, their session will stay forever unless you have a system in place for clearing out old sessions.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.