pranshu82202 Posted September 6, 2011 Share Posted September 6, 2011 I want to know how can i check wether the user is online on my website or not.... Quote Link to comment https://forums.phpfreaks.com/topic/246570-online-status/ Share on other sites More sharing options...
flappy_warbucks Posted September 6, 2011 Share Posted September 6, 2011 Phone them up and ask them? Seriously: log the IP address, and time they last clicked a link. (to save DB space, prob best as a flat file system unless you got a large database capacity). Then you can write a script to show when they last clicked a link. with a time limit of 5 minutes per click, that should be a reasonable indication of when they're online, and what page they're on. Quote Link to comment https://forums.phpfreaks.com/topic/246570-online-status/#findComment-1266147 Share on other sites More sharing options...
pranshu82202 Posted September 6, 2011 Author Share Posted September 6, 2011 dude you really suck.... is anyone here other then flappy_warbucks.... Quote Link to comment https://forums.phpfreaks.com/topic/246570-online-status/#findComment-1266149 Share on other sites More sharing options...
Psycho Posted September 6, 2011 Share Posted September 6, 2011 You can't "check" their status. You can update the last time they accessed your site. Just add a function that will run on every page load to update a "last_access" timestamp for users whenever they load a page. Then, determine who is "online" based upon that timestamp, by choosing an appropriate time period: e.g. any users who's "last_access" time is within the last 10 minutes (or whatever period you want to use). log the IP address, and time they last clicked a link. (to save DB space, prob best as a flat file system unless you got a large database capacity). A flat file, seriously? How does a flat file save space over a database? Plus, since this will be updated every time a users access a page and when you need to get the data there is a huge possibility for file corruption. Quote Link to comment https://forums.phpfreaks.com/topic/246570-online-status/#findComment-1266152 Share on other sites More sharing options...
pranshu82202 Posted September 6, 2011 Author Share Posted September 6, 2011 thanx mjdamato but what if the user is sleeping and he is online (means the website is open for an hour or two).... Quote Link to comment https://forums.phpfreaks.com/topic/246570-online-status/#findComment-1266155 Share on other sites More sharing options...
Pikachu2000 Posted September 6, 2011 Share Posted September 6, 2011 http is a stateless, connectionless protocol, so it doesn't matter if the browser has your site loaded and just sits there. Quote Link to comment https://forums.phpfreaks.com/topic/246570-online-status/#findComment-1266156 Share on other sites More sharing options...
pranshu82202 Posted September 6, 2011 Author Share Posted September 6, 2011 you are not getting me guyzz... i am saying that if my website is opened in any users X browser (but not doing anything on it from several hour) and user Y want to send a PM to user X only if Y knows that X can instanty reply to it...... then how would user Y came to know that user X is online.. Quote Link to comment https://forums.phpfreaks.com/topic/246570-online-status/#findComment-1266160 Share on other sites More sharing options...
WebStyles Posted September 6, 2011 Share Posted September 6, 2011 set an incativity timeout and force them to logout if there's no activity for x minutes. Quote Link to comment https://forums.phpfreaks.com/topic/246570-online-status/#findComment-1266180 Share on other sites More sharing options...
Pikachu2000 Posted September 6, 2011 Share Posted September 6, 2011 you are not getting me guyzz... i am saying that if my website is opened in any users X browser (but not doing anything on it from several hour) and user Y want to send a PM to user X only if Y knows that X can instanty reply to it...... then how would user Y came to know that user X is online. I understand perfectly what you want to do, and I also understand perfectly the reasons it doesn't work like that. Aside from setting up some elaborate, resource-wasting system using keepalive messages with JS/AJAX, the best you can do is log the time of the last activity of the user, and if it's been more than a predetermined amount of time since they last did anything, consider them inactive/unreachable/deceased/drowned/whatever. Just like mjdamato and flappy_warbucks said. Quote Link to comment https://forums.phpfreaks.com/topic/246570-online-status/#findComment-1266196 Share on other sites More sharing options...
WebStyles Posted September 6, 2011 Share Posted September 6, 2011 consider them inactive/unreachable/deceased/drowned/whatever. apparently sleeping is the order of the day... who are all these people suddenly sleeping in front of the computer? Quote Link to comment https://forums.phpfreaks.com/topic/246570-online-status/#findComment-1266200 Share on other sites More sharing options...
Psycho Posted September 6, 2011 Share Posted September 6, 2011 but what if the user is sleeping and he is online (means the website is open for an hour or two).... you are not getting me guyzz... As others have stated, youzz are the one not getting it. If you followed the advice given and a user left their browser open to your site (with no activity) for two hours then they would not be seen as "online" since it would have been more than 15 minutes (or whatever period you set) since their last activity. Quote Link to comment https://forums.phpfreaks.com/topic/246570-online-status/#findComment-1266218 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.