0

Okay, I pretty much have it sussed out. But I'm stuck where to reset their '$time' to 00:00:00 after they become inactive from the website. As currently, if they log in.. They become active, and remain so no matter what.

Here's my code :

 $user = $_SESSION['username'];
 $time = time();
 mysql_query("UPDATE `users` SET `online` = $time WHERE `user_id` = $user_id");

 $time = $time - 100;
 $online_user = mysql_query("SELECT * FROM `users` WHERE `online` >= '$time'");

 while($users_row = mysql_fetch_array($online_user)){
     $user = $users_row['username'];    
     $online .= "$user, ";
 }

That checks the user is online etc and creates the format for them to be displayed

echo '<font size="2">Who\'s Online : </font>';
echo '<br><font size="1" color="green">';
echo $online;   
echo '</font>'

And that is on the footer.

  • You may want to consider storing your online list in memcached. You probably don't need persistent storage for it. – Paul Apr 26 '13 at 23:36
  • 1
    You have to check the time and kill the session this post should help: http://stackoverflow.com/questions/3068744/php-session-timeout – obsirdian Apr 26 '13 at 23:38
  • @kaisok he is not trying to kick out a user after a certain amount of time, so that doesn't help – markasoftware Apr 27 '13 at 00:51
  • @Markasoftware I think that's exactly what he's trying to do. Please give an answer or propose an edit to clarify the question if you have a different opinion, so everyone can see it and decide. Thanks. – obsirdian Apr 27 '13 at 13:24
  • 1
    @kaisok I think he is trying to remove you from the list of online users when you leave the website, not kick you out after a certain amount of time. – markasoftware Apr 27 '13 at 21:49
  • @Markasoftware, I think we're saying the same thing. Removing someone from the list of online users would also kick them out. The list of online users is (or should be) determined by active sessions. – obsirdian Apr 29 '13 at 02:01
  • @kaisok he wants them to be removed from the list when they leave the website, it has nothing to do with kicking the user out of the website after a certain amount of time. – markasoftware Apr 29 '13 at 03:16

0 Answers0