Is there a way to see all sessions and their variables on my server?
I want to see who is logged in by looking at the 'login' session variable of that user.
Or do i have to Update something in database when user logs in and out?
Is there a way to see all sessions and their variables on my server?
I want to see who is logged in by looking at the 'login' session variable of that user.
Or do i have to Update something in database when user logs in and out?
What you want could be done in a better way (as you mentioned, you should store the logged users in a db), but here's something that might be useful for you, check this out:
PHP stores session data for each user in a temporary folder on the server. This folder is defined in the php.ini configuration file under the variable session.save_path. Locate this value from within your php.ini file, or alternatively, create a php file with:
<?php echo "Session Save Path: " . ini_get( 'session.save_path');?>
as it's contents, and open the file in your browser.Once you find the save path for the session data, open up that folder and you'll notice a fairly simple structure. All sessions are stored in the format:
sess_$SESSIONID
.Session data is serialized before being stored on disk. As such, objects stored in the session file would have to be deserialized before being usable. However, if you're using plain text, which is stored as-is, to store your session data (ex.
$_SESSION['userid'] = 1234
) to store information about your users, it should be easy enough to parse out the data you're looking for from within the files.
From there you can get an idea of what you want to do, but it would be easier to save the session in database.