dcsimg
Session Handling if User clicks 'Back' Button on Browser to LogIn again.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rupali_Deshmukh
Posted On:   Friday, November 30, 2001 05:24 AM

My problem is: I m using a HashMap object to store User Session. If the User properly LogOuts, his session removed from HasMap and also Invalidated. If he closes the browser window & Logs Back Again the code checks the HashMap to see whether he is an old User & if so Invalidates his Old Session and assigns him a New Session. But... If he Clicks on Back Button on Browser and tried to Log Back Again without Logging Out, it gives an Error: Session Already Invalidated if I try to use the setAttribute() Method. Why So? What Exactly Happens in this situation? Can Someone Help Me Out?    More>>


My problem is:
I m using a HashMap object to store User Session.

If the User properly LogOuts, his session removed from HasMap and also Invalidated.

If he closes the browser window & Logs Back Again the code checks the HashMap to see whether he is an old User & if so Invalidates his Old Session and assigns him a New Session.

But...

If he Clicks on Back Button on Browser and tried to Log Back Again without Logging Out, it gives an Error: Session Already Invalidated if I try to use the setAttribute() Method.

Why So? What Exactly Happens in this situation? Can Someone Help Me Out?

   <<Less

Re: Session Handling if User clicks 'Back' Button on Browser to LogIn again.

Posted By:   Steven_Martin  
Posted On:   Friday, November 30, 2001 06:23 AM

Here's some code that will demonstrate how to restart a session without closing the browser. Enter the jsp once and it will display null. Refresh the page and you will get hello world. Note that you can't use the 'session' variable after you have invalidated. You have to request.getSession(true) to get a handle.



<%@page contentType="text/html"%>

JSP Page


<%=session.getAttribute("hello")%>
<%session.invalidate();%>
<%request.getSession(true).setAttribute("hello", "hello world");%>



About | Sitemap | Contact