[Solved] User still online after closing page


Indeed, that’s the way sessions typically work. Once a page is loaded, there’s no connection between the browser and the server anymore. Basically, once a page has finished loading and is just sitting there in the browser, it’s already the same as if the user had closed the window.

There’s no way to 100% reliably detect whether a user is still “online” or not. You’d have to have a Javascript send a constant heartbeat for that, but even with this it comes down to timeouts. If you have not seen the user for a certain amount of time, assume he is offline and delete the session. That’s all you can do.

5

solved User still online after closing page