Why session is not null after session.invalidate() in JAVA?

前端 未结 3 1004
南方客
南方客 2020-12-16 01:01

I am facing very strange problem while developing JavaEE WEB Application.

Even after invalidating the HttpSession using session.invalidate();

3条回答
  •  误落风尘
    2020-12-16 01:31

    Try passing false as the parameter to the getSession(boolean) . This will give back a session if it exists or else it will return null.

    HttpSession session = request.getSession(false);
    if(session==null || !request.isRequestedSessionIdValid() )
    {
        //comes here when session is invalid.
    
    }
    

提交回复
热议问题