Jump to content

User sessions to determine accounts logged in


plznty
 Share

Recommended Posts

I would like my website to show which users are logged in.

Is there a simple way of retrieving all session ids from the server that have been allocated and are active in order to do this?

I know this could lead to faulty information, but would appear to be the simplest and reliable.

Thanks.

Link to comment
Share on other sites

is session information stored at the server or in the users browser?

 

I would think the best way for this would be to set a flag in your db that says if they're logged in or not.. This wouldn't be very hard at all if you already have a users table with their information.

 

I'm not very well versed in sessions though, so I could be incorrect with my assumption above.

 

Denno

Link to comment
Share on other sites

<?php
echo ini_get( 'session.save_path');
?>

 

whats where all the sessions are stored.. Just make a script to calculate how many files are in that folder... thats how many active sessions there are.

 

That won't get you 'who' is logged in. The method denno020 suggested is the typical method used. You simply update a timestamp every time a user hits a page. You then (where you want to display the logged in users) query for all users with a timestamp within the last ten minutes and display them, the rest can be removed (all in this same process).

Link to comment
Share on other sites

<?php
echo ini_get( 'session.save_path');
?>

 

whats where all the sessions are stored.. Just make a script to calculate how many files are in that folder... thats how many active sessions there are.

 

That won't get you 'who' is logged in. The method denno020 suggested is the typical method used. You simply update a timestamp every time a user hits a page. You then (where you want to display the logged in users) query for all users with a timestamp within the last ten minutes and display them, the rest can be removed (all in this same process).

 

ahh yes, didn't fully read his post... you're right

Link to comment
Share on other sites

This thread is more than a year old.

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.

 Share

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