When a PC closes a browser, the session on the server is still alive. When the same PC opens up another browser I want to invalidate the first session from the new session. This is to prevent many sessions for the same PC on the server. Is there a way to do this? Thanks.
BJ - SCJP and SCWCD
We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design
To my knowledge the HttpSessionAttributeListener interface is useful only to get notified whenever an attribute is added/removed/changed in the session. In fact you have interface (HttpSessionBindingListener) which can be used to get notified when a session gets expired or invalidated. But you don�t have anything handy for your requirement. Please let us know your logic of using HttpSessionAttributeListener for this requirement. In my way, the best way to do is to invalidate the session when closing the browser rather than keeping it in the server till you create the next session or session timeout. You can do this by calling a java script function in the onUnload event of the page and invalidate the session using invalidate() method of the session object. Note: onUnload function would be triggered even when you close the browser. If someone have a better solution to the requirement or any conflict to my view, please let me know. - VJ
subject: Invalidate one session from another session.