0

I'm working web project that I need to check if user is already logged in login page, I know that I can create an class that implements ServletContextListener and its in contextInitialized method, I create a map that the key is id of user, for example. But my question is, How am I going to control this when user close the browser?

Thanks

  • the traditional way is to create a HttpSession object and store something there when the user is logged – Leo Apr 10 '14 at 13:25
  • I am sorry, you mean you want one user logged at a time (and not 2 instances logged by the same user), right? – Leo Apr 10 '14 at 13:29
  • you can't really detect when the user close the browser, but you can use some polling mechanism to check/log every X seconds if there is still some active instance logged by that user – Leo Apr 10 '14 at 13:31
  • yes, I can't let two user sign in on the system that the same login – Alisson Vieira Apr 10 '14 at 14:19
  • check this out http://stackoverflow.com/questions/10782968/allow-only-one-session-per-user – Leo Apr 10 '14 at 18:39

0 Answers0