The simplest way to do this is to make a column to store the last time the user was active. E.g:
// Before end of script
$time = time();
mysql_query("UPDATE Members SET last_active='$time' WHERE memberid=$memberid", $con);
Then to check if a user is online or not, choose a window of activity(say, 1 minute).
$inactive = bcsub(time(), 60);
$query = "SELECT * FROM Members WHERE last_active > $inactive";
$result = mysql_query($query, $con);
One thing to keep in mind: Some users may not log out, or may just go away from the comp with the window still up, leaving their session active far past when they should really be considered online. Figure out how you want to define an "online" user.
Last edited by Lsmjudoka; Jul 30th, 2010 at 2:53 am.
Reputation Points: 10
Solved Threads: 9
Junior Poster in Training
Offline 72 posts
since Apr 2009