This question already has an answer here:
In my database i inserted a column named "online" with a default value of 0. So when a user log in this value is updated to 1 so now it says the user is online. When a user click on log out this value gets updated to 0 again so now the user is offline. But i was thinking, what if the user just closed the browser without signing out, nothing will get updated and the user will stay online. Can you please help with guidance to how can I work this out ? Is there anyway of doing this with javascript or jquery ajax that detects when the browser is closed ?
</div>