Jump to content

run php when closing browser window?


tomjones

Recommended Posts

Hi.

I am creating a login component which stores a simple Y/N value in a MySQL database depending on if the login was successful or not. I need to somehow reset this to N when the user closes the browser window. What would be the best way to achieve this with PHP? I can create the sql statement, but how would I go about running a function when the window is closed?

Thank you for your time.
Link to comment
Share on other sites

I dont think this is possible, Powecuts, Illegal Shut downs ect

The best way to find out who is online is
add a field into the DB, last_action or something, as DATETIME field
On the top of every page, have a script
If the user is logged in,
Update the table with last action of that date time

Anyone who has action within the last 10 minutes you can assume they are online
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.