I am working on a web based application.I want to restrict the number of users by 2. I am using listener class to count the sessions. My problem is that when user closes the window directly(without logout),How to count active sessions. It is happening that when somebody closes the application (without logout),the session counter will not decrement. I am facing this problem as i dont find any event to handle active sessions count with above said problem.