Styles2304 Posted April 21, 2008 Share Posted April 21, 2008 I wasn't exactly sure how to word the subject so I apologize. Basically, when someone logs in, it stores there onlinestatus value as 1 which is in turn accessed on the profile page and an image is displayed based on the value. Blah blah blah you get the idea. My question is, how do I have that value set to zero once the person is logged out but doesn't use the logout button to do so ex: X's out the window and the session is ended. Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 Rather then storing 1 or 0 for logged in or out, store the time of their last activity. Then on your profile page, if they havn't had any activity for X many minutes, then they are displayed as 'logged out'. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 dptr has the right idea. You don't want a real "onlinestatus" column, you want a last_activity column which updates on every page, and if the profile page is accessed, it checks the current time against the last_activity to see if they were active in the last...say, 5 minutes. Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted April 21, 2008 Author Share Posted April 21, 2008 So just open up a session variable with the username or something and then everytime a page is loaded, store the current time on the database? That makes sense . . .then I'll just check the last active time against the current time. Purely playing the devil's advocate here . . . what if the person is just updating their profile for like 15 minutes and they haven't hit any buttons or loaded any pages? Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 Purely playing the devil's advocate here . . . what if the person is just updating their profile for like 15 minutes and they haven't hit any buttons or loaded any pages? That's just one of the disadvantes of the HTTP protocol. The server has to wait for the client, and if the client doesn't respond within a certain time, there is nothing you can do about it. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 21, 2008 Share Posted April 21, 2008 So just open up a session variable with the username or something and then everytime a page is loaded, store the current time on the database? That makes sense . . .then I'll just check the last active time against the current time. Purely playing the devil's advocate here . . . what if the person is just updating their profile for like 15 minutes and they haven't hit any buttons or loaded any pages? Then it's safe to say that they can be considered "offline" without radically affecting your life. =P It's not too big of a deal. It's like idling on AIM or MSN. You might be there, but you might not be, and people message you anyway. Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted April 21, 2008 Author Share Posted April 21, 2008 Is that what myspace does? Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 21, 2008 Share Posted April 21, 2008 I don't know how they handle it, but the method we describe here is the only one I have seen used, so I'm sure they use it too. Quote Link to comment Share on other sites More sharing options...
Styles2304 Posted April 21, 2008 Author Share Posted April 21, 2008 roger . . . fair enough. Thanks for the help guys! 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.