Session getting open when I close the browser

0

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?

    
asked by anonymous 07.04.2017 / 14:56

1 answer

1

I think the model you chose (one session per user) generates a very high control cost for a very small benefit value. You're basically struggling with the multi-device identity paradigm.

Given the very nature of the HTTP protocol and the behavior of browsers (where a permanent connection to the web server is not guaranteed), I would try another approach: allow a user to have one or more sessions. Map your operations per session, not per user.

    
07.04.2017 / 15:16