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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.