Hi to all! How can I invalidate a session having it's session id? I want to make a function that allow an administrator user to invalidate the session of others users that are logged in my web application (and so force them to log out). Now I store the session id of all users that are logged in on a db table. But how can I call session.invalidate() on a particular session id?
As I recall, early versions of the servlet API had a method to get at an arbitrary session by the ID but the methods were removed as a security risk. You will have to think of another way to accomplish your goal. Bill
Maybe you can signal the session to kill itself. Just intercept the calls and check if a flag has been risen in that case tell the session to invalidate itself. It will just add a filter to your app. The hard thing will be to keep record of all active sessions.
She will remember your heart when men are fairy tales in books written by rabbits.<br /> As long as there is duct tape... there is also hope.
Since the servlet API no longer directly lets you get to other sessions, one way this could be done would be to make a custom listener that implements the HttpSessionListener, and register it in the web.xml, so as a session is created in the system, your listener would store a reference to that session into a hash table (within the servlet context attributes?) possibly keyed by session identifier. It is not really cluster friendly, or reload of webapp friendly and you should remove the session from your map in the sessionDestroyed() of the listener.
Then your admin page can consume this map, and invoke invalidate() on selected sessions.
Error: Keyboard not attached. Press F1 to continue.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com