public static void clearInvalidSessions ( final Principal user ) { logger . info ( "Clearing invalid sessions for user {} ({})" , user . getName ( ) , user . getUuid ( ) ) ; final PropertyKey < String [ ] > sessionIdKey = StructrApp . key ( Principal . class , "sessionIds" ) ; final String [ ] sessionIds = user . getProperty ( sessionIdKey ) ; if ( sessionIds != null && sessionIds . length > 0 ) { final SessionCache sessionCache = Services . getInstance ( ) . getService ( HttpService . class ) . getSessionCache ( ) ; for ( final String sessionId : sessionIds ) { HttpSession session = null ; try { session = sessionCache . get ( sessionId ) ; } catch ( Exception ex ) { logger . warn ( "Unable to retrieve session " + sessionId + " from session cache:" , ex ) ; } if ( session == null || SessionHelper . isSessionTimedOut ( session ) ) { SessionHelper . clearSession ( sessionId ) ; } } } }
Remove old sessionIds of the given user