Search code examples
sessiontimeoutwebspherecommerce

Is there a way to force a user session timeout in Websphere?


I need to do some testing to the session timeout logic and how timeouts are handled, but I don't want to have to wait for the session to time out. Right now it takes 30 minutes of inactivity to time out, is there a way to either change this to a much lower timeframe or, even better, force the timeout whenever I want?


Solution

  • You can invalidate the HTTP Session, which is very similar to what occurs during a timeout, by calling HTTPSession#invalidate. You could do this trivially with a JSP.

    HttpSession session = request.getSession(false);
    if (session != null) { 
        session.invalidate();
    }
    

    You can also adjust the timeouts at the application level in the WAS console:

    All Applications > $yourapp > Session management