Jump to content

Checking When A User Exits The Site And Update Mysql Table Upon Exit (SOLVED)


skatermike21988

Recommended Posts

just make a table in the users profile

so when a user logs out (if using a form)

update thier profile saying their offline
and 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?
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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??
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.