Jump to content

[SOLVED] Automatically Modifying values in database


Styles2304

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.