skatermike21988 Posted September 22, 2006 Share Posted September 22, 2006 Hello,I have a community script that when a user is logged in it displays it on their profile, right now the only way for it to show them offline is to click the logout link. I want to be able to update the table and set online=0 when a user exits the website.Any and all help is appreciated Quote Link to comment Share on other sites More sharing options...
Demonic Posted September 22, 2006 Share Posted September 22, 2006 just make a table in the users profileso when a user logs out (if using a form)update thier profile saying their offlineand when they login update profile to say hes online :).also if your using cookies it would be best to make the table default offline :) say they havent registered yet know what i mean? Quote Link to comment Share on other sites More sharing options...
skatermike21988 Posted September 22, 2006 Author Share Posted September 22, 2006 ok i already have it like that, but if they exit the browser they are no longer logged in, but on their profile it will say they are, becuase they didn't actually "logout" they exited, thus my table isn't updated Quote Link to comment Share on other sites More sharing options...
btherl Posted September 22, 2006 Share Posted September 22, 2006 The only solution for that is a timeout. If you record the last activity of each user, then you can have some code which checks if a user has not done anything for a certain amount of time. If they haven't, then you mark them offline. You don't have to log them out, just make them appear offline to others since they are inactive.You can either have it run as a regular job (like a cron script), or have it run each time a page is loaded. A common strategy is to have it run at random, say every 1 in 10 page loads. The right frequency depends on how often your pages get hit.Unfortunately there is no way to detect them closing the browser. Quote Link to comment Share on other sites More sharing options...
skatermike21988 Posted September 22, 2006 Author Share Posted September 22, 2006 ok so i could everytime the user is active have it insert the time into the database and have a script pull that time out and like add say like 10 minutes to it and if it equals or is greater then have the script update the mysql, and if the user becomes active again have it update it back to online, something like that. correct?? Quote Link to comment Share on other sites More sharing options...
skatermike21988 Posted September 22, 2006 Author Share Posted September 22, 2006 Ok i got something that together that works, thanks for the help Quote Link to comment 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.