Close/kill the session when the browser or tab is closed

You can’t. HTTP is a stateless protocol, so you can’t tell when a user has closed their browser or they are simply sitting there with an open browser window doing nothing.

That’s why sessions have a timeout – you can try and reduce the timeout in order to close inactive sessions faster, but this may cause legitimate users to have their session timeout early.

Leave a Comment