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
Post a Comment