I have a user control that stores a list of logged-in users on the system. Together with each user, I keep the id of the session that is logged in. Each session lasts around 20 without the user tinkering with the system. I do not allow the same user with different session id to avoid conflict in operations. If I call the login screen and an id already exists on the system, I automatically retrieve the user and redirect to the system start screen. If a user logged in with the session id already exists, a question is asked if you want to override the other session of the system.
My problem is that when I close the browser, the session remains open on the system, and when I reopen the same browser the session id is changed and identifies as if I already had another user logged into the system. I wanted when I close the browser to log out on the system. I was using the onbeforeunload command but it fires when I refresh the screen and when I call a new screen.
Would you like to check that there is no browser logged in with the session (HttpSession) that is in the list of AplicationScope?
Or maybe check if the flap or browser is actually being closed and not updated?