I want to prohibit the user from going back to a secure page after logout when he/she clicks on the back button on the browser(in my case it is Mozilla Firefox 5.0). Found two ways, setting proper headers:
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.setHeader("Pragma", "No-cache");
response.setDateHeader("Expires", 0);
or disabling the back button using javascript:
<script type="text/javascript">
window.history.forward(1);
</script>
actually the javascript doesn't disable the back button,just forwards the user one page ahead in the history,should serve the purpose.
But neither works. My logout page is contains the following code:
<script type="text/javascript">
window.history.forward(1);
</script>
<% HttpSession ses=request.getSession(false);
ses.invalidate();
String referer = request.getHeader("Referer");
response.sendRedirect(referer);
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.setHeader("Pragma", "No-cache");
response.setDateHeader("Expires", 0);
%>
Doesn't serve my purpose.Please help.