How to cancel a browser session

How can I cancel a browser session. I am using JSP. The web.xmlparameter is session-timeoutset to 180 seconds, and I want it to be like that. But the problem is that for some user browser sessions, you must immediately cancel immediately after submitting the form.

I used session.invalidate();to cancel the session and also used

response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);

But still, when I click the back button, it will lead me to the same user session. Is this loading from the browser cache?

This is what I have in my JSP:

<head>
<script type="text/javascript">
function submitForm(){window.document.submitFrm.submit();}
</script>
</head>
<body onload="submitForm()">
<%String output = (String)(request.getAttribute("strOut"));
String hookUrl = (String)(request.getAttribute("hookUrl"));
System.out.println("hookUrl in cwsGroup.jsp : "+hookUrl);%>
<form method="post" action="<%=hookUrl%>" name="submitFrm" id="submitFrm">
<input type="hidden"  name="cxml-urlencoded" value='<%=output%>' />
</form>
<%
response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader( "Expires", 0 );
session.removeValue("domineName");
session.invalidate();%>
</body>

Did I miss something?

+3
source share
2 answers

These headers are incomplete. This will only work in Internet Explorer, but will not work in others. Full set

response.setHeader("Cache-Control","no-cache,no-store,must-revalidate");
response.setHeader("Pragma","no-cache");
response.setDateHeader("Expires", 0);

JSP. JSP JSP. JSP (). , Filter , *.jsp. , . .

+4

, onclicking back . , , "". , .

"<" ">" lasr-

<script type="text/javascript">

      bajb_backdetect.OnBack = function()
      {

        alert('You clicked it!');

      }

<script>
+1

All Articles