How to detect whether the session is live or not?
1 posts in topic
Flat View  Flat View

Posted By:   Jason_Lee
Posted On:   Wednesday, April 18, 2001 11:47 PM

Assume that the web server creates a new session for a user, and later, the user does not "log out", but rather just closes the browser. How can the web server determine that this session is no longer active and prevent it from consuming valuable server resources?

Re: How to detect whether the session is live or not?

Posted By:   AlessandroA_Garbagnati  
Posted On:   Thursday, April 19, 2001 12:21 AM

There is no "standard" way to have a count of all the "active" sessions in a servet container. You have top maintain your own, maybe using a map that stores the session when the user logs in and remove it when the user logs out.

If the user doesn't log out properly, you can check if the session is still valid based on computing the time difference between the default timeout interval (HttpSession.getMaxInactiveInterval()) and the last activity performed by the user (HttpSession.getLastAccessedTime()).

About | Sitemap | Contact