title: Destroy user session stored in database on window close
body: <p>In our JAVA web application we maintain users' session in a database table <code>active_sessions</code>. And we do not allow multiple sessions per user. what it means is, if you are already logged in with a particular user account, you cannot open a new session with the same account. In case somebody does, we display error 'User already has an active session'. When user clicks on <code>Logout</code> his entry from table <code>active_sessions</code> is removed. But in case where user closes the window without logging out his entry remains in the table <code>active_sessions</code>. So any attempt to login in future results in an error 'User already has an active session'. Any tips on how to destroy user session in database in case he closes the browser window without logging out.</p>
  
  <p>Edit: After reading all the posts it seems there is no clean way to restrict single session per user.</p>