I search this site and google, but didn't find anything that helped. I have a program that creates a session when a user is logged in. My database sets the user as online until the user click on exit button. Then the user is set to offline in the database offline. This is so a user can login in one place only. The trouble is when the user doesn't click the exit button, but closes the browser or tab or when the computer turned off. When this happens the user is still set as online in the database and can not login again. I then have to use the admin area to manually exit the user.
How can I know on server side if the user is online or when thethe user closes the browser or has turned off their pc?
I know about the onbeforeunload
or onunload
javascript but don't think it can help because I must close session and set the database user is offline which the time to do this I think is so low.