• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 705
  • Last Modified:

Does HttpSession.invalidate function kill all the sessions?

I have 2 webserver, each one tied with an app server.  The session timeout has been set to 4 hours.  But sometimes after couple of minutes, the user is kicked back to the login page.  I am not sure if HttpSession.invalidate is the cause?  Pls advise.

Thanks.
0
radha77
Asked:
radha77
  • 2
1 Solution
 
Ryan ChongCommented:
Yes, the invalidate() method DID kill all the sessions, to kill only a particular session object, try use the removeAttribute method:

Example:

<%

session.setAttribute("test", "124");

out.println(session.getAttribute("test")+"<br>");

session.removeAttribute("test");

out.println(session.getAttribute("test")+"<br>");

%>

Hope this helps
0
 
radha77Author Commented:
Thank you.  I have another question ... What is "test" and "124" in session.setAttribute("test", "124");  Is that any random name, or does it have to be the userid?  Pls advise.

Thanks.
0
 
Ryan ChongCommented:
>>Is that any random name, or does it have to be the userid
Possible, above is just an example on how to kill a particular session object. "test" will be the object name, while "124" is the value associated within the session object.

Hope this's clear, cheers :-)
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now