DarrenReeder Posted December 9, 2009 Share Posted December 9, 2009 Hello, I am trying to make a 'All players logged' on my site and i want to make it so i see all the sessions that are connected to the site, then dispay them all... OR is it possible that if i have a field called 'logged' and When yuo connect it sets to '1' then if you close the browser/logout it sets to '0'? thiss seems a bit more dodgey though Quote Link to comment Share on other sites More sharing options...
cags Posted December 9, 2009 Share Posted December 9, 2009 There is no way of changing a value via PHP when the user closes the browser or navigates away from your page, the only way that would work is if your users always use the logout link you provide for them. One way round it is to have a last_action value stored. Each time the user performs a request to your site, (ie loads a page, if you wish to allow people to idle you could use AJAX to force the requests) you update this timer, you can then either have a scipt ran via cRON jobs to remove inactive users every x amount of minutes or you can make clients trigger the action. In other words when somebody requests this list of 'online users' it trims it down before displaying it. Quote Link to comment Share on other sites More sharing options...
DarrenReeder Posted December 9, 2009 Author Share Posted December 9, 2009 so.. i have like a field in my table for a NOW() thingy...and wen u check online soldiers it will only show people who have now()-120 in that field... if thats wat u mean? Quote Link to comment Share on other sites More sharing options...
cags Posted December 9, 2009 Share Posted December 9, 2009 Essentially speaking, yes. Quote Link to comment Share on other sites More sharing options...
DarrenReeder Posted December 9, 2009 Author Share Posted December 9, 2009 hmm..right...thanks alot.. i got a 'stats' frame on the page that auto refreshes every 15 seconds so i can just use that :D:D Quote Link to comment Share on other sites More sharing options...
atomicrabbit Posted December 9, 2009 Share Posted December 9, 2009 This is just theory, but can't you use <body onUnload="someJavascriptFunction();"> to check if the user is navigating away from the page and then just use some javascript/ajax to set the 1 to 0 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.