Jump to content

[SOLVED] How to catch a "close the browser" event


needs_upgrade

Recommended Posts

Hi guys!

 

I store online users in mysql database. My problem is that some users don't use the logout button but directly closes the web browser. As a result, their user IDs are still in the database. I want to catch the event whenever the users closes the browser. Or sometimes the browser crashes. I would like to catch that as well. How can i do that?

 

Thanks so much guys.

Link to comment
Share on other sites

Oh right, no lol.

Well...great minds think alike :-*

 

I personally check if users are online on my site by updating a timestamp for that user in the database every page they visit.

Then, if their timestamp is older than five minutes, I consider them offline. I've found this to work pretty well, as you can get stats like how many guests online, how many users, how long they've been online for etc.

 

Only problem is it's pretty db intensive.

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.