deathadder Posted November 11, 2012 Share Posted November 11, 2012 Ok, so i have it working by setting the cookie time to 300 seconds(5 minutes), and i also have it so if you click logout it deletes cookie, and sessions + sets status field to offline, i also have a script in the config file that checks if the user has had any activity for the last 500 seconds, if it has it resets the time() for the user, if not it logs them out. what im having trouble with is making a user online list, if they do not refresh their status will be set to online forever, can anyone help me here? Quote Link to comment https://forums.phpfreaks.com/topic/270556-checking-if-logged-in-or-notdifferent-to-my-other-post/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 11, 2012 Share Posted November 11, 2012 Your database table that you are using to store the 'online' user information, needs to store the 'last access time' for each user. Then, when you are displaying the 'online' list, you only retrieve the records where the 'last access time' is within x seconds of the current time. Or you can just delete the records where the 'last access time' is older than x seconds from the current time and display the remaining records. Quote Link to comment https://forums.phpfreaks.com/topic/270556-checking-if-logged-in-or-notdifferent-to-my-other-post/#findComment-1391715 Share on other sites More sharing options...
deathadder Posted November 12, 2012 Author Share Posted November 12, 2012 i have an idea, at school i was thinking about this, and came up with the idea to check if the timestamp is older then 15 minutes old on the online list, ill be back if it does not work Quote Link to comment https://forums.phpfreaks.com/topic/270556-checking-if-logged-in-or-notdifferent-to-my-other-post/#findComment-1391792 Share on other sites More sharing options...
deathadder Posted November 12, 2012 Author Share Posted November 12, 2012 EDIT: i have a problem, my previous theory did not work, so i retried what you said, i wrote up this code but it selects all users timestamps, and whenever one person does an action it uses that as previous action time for all. <? include 'config.php'; session_start(); $SQL = mysql_query("SELECT * FROM users"); $dbfield = mysql_fetch_assoc($SQL); $inactive = 900; $current_time = time(); $prev_time = $dbfield['timestamp']; $query = $current_time - $prev_time > $inactive; $SQL2 = mysql_query("SELECT * FROM users WHERE timestamp = '$query' AND online='online'") or die(mysql_error()); $dbfield2 = mysql_fetch_assoc($SQL2); $count = mysql_num_rows($SQL2); echo $current_time - $prev_time; echo '<br />'; echo $count; ?> here is the code, can you please tell me what i need to do to fix this? Quote Link to comment https://forums.phpfreaks.com/topic/270556-checking-if-logged-in-or-notdifferent-to-my-other-post/#findComment-1391795 Share on other sites More sharing options...
trq Posted November 12, 2012 Share Posted November 12, 2012 You know what the problem is, all you need to do is learn how to think your problem through. Quote Link to comment https://forums.phpfreaks.com/topic/270556-checking-if-logged-in-or-notdifferent-to-my-other-post/#findComment-1391802 Share on other sites More sharing options...
deathadder Posted November 12, 2012 Author Share Posted November 12, 2012 ik what the problem is it is searching all users, and upating all timestamps, but i have no idea how to fix it. Quote Link to comment https://forums.phpfreaks.com/topic/270556-checking-if-logged-in-or-notdifferent-to-my-other-post/#findComment-1391807 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.