Forums Register Login

Invalidate one session from another session.

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
HttpSessionAttributeListener solved the problem.
Thanks
+Pie Number of slices to send: Send
Bruce,
How do you check it is the same user? IP Address?
+Pie Number of slices to send: Send
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
Good night. Drive safely. Here's a tiny ad for the road:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1484 times.
Similar Threads
Session gets destroyed when invoking application of another server in a same browser
Session problem in Struts and Tomcat
session management -session not destroying automatically
session object
sendRedirect()
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:00:05.