public static void clearSession ( HttpServletRequest req ) { SecurityContextHolder . clearContext ( ) ; if ( req != null ) { HttpSession session = req . getSession ( false ) ; if ( session != null ) { session . invalidate ( ) ; } } }
Clears the session . Deletes cookies and clears the security context .