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
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.
Link to comment
Share on other sites

Thanks for the reply.

I was of course going to pair this information with a database, but the problem for me was knowing how long a user has been logged in, and when they sign off.

Similar to the "Total time logged in:" function of these php forums.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.