java - Can I expire all sessions of a user? -


can expire sessions of user?
know can expire session using session.invalidate().

i using tomcat, servlet/jsp.

in session have attribute userid.

on basis define session belongs particular user.

i have need in have invalidate sessions containing particular userid.

use this code manage active sessions , session id, can call session , invalidate once needed:

 public class sessionlistener implements httpsessionlistener   {         private static map<string, httpsession> map = new                                         hashmap<string, httpsession>();        public void sessioncreated(httpsessionevent event)       {           string id = event.getsession().getid();           logger.debug("session created : " + id);           // store sessoin example in database          map.put(id, event.getsession());       }        public static httpsession gethttpsession(string sessionid)       {           return sessionobjectmap.get(sessionid);       }        public void sessiondestroyed(httpsessionevent event)       {           // destroying session...                    }   }  

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -