Jump to content

Display The Names From Online Users


garevn

Recommended Posts

i think according to me you just add one more column to your database as status . when your user process for login.. after successful login just update status as a online otherwise default was offline (you can use true/false or 1/0) or copy logged in users data to your new table where you want to store logged in users and same for offline users.

Link to comment
Share on other sites

i don't think you really have to do much, other than add a last_logged_in column to each user in your user table. Basically, everytime a user successfully logins, update the timestamp in the user table with the timestamp of that particular users login time. Your currently logged in users could be all users who's last_logged_in time falls within a specified criteria, i..e the past 15 minutes, 30 minutes, 1 hour, etc.http://www.w3schools.../sql_update.asp

Edited by thescientist
Link to comment
Share on other sites

Rather than last_logged_in I'd have a last_activity field. Anytime the user loads a page this timestamp is updated. To find out which users are online, check the difference between now and that date.

$now = time();

SELECT username FROM users WHERE ($now - last_activity) < 900

900 means 15 minutes, 900 seconds.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...