hi
I have a simple log in form.
I want that after user logs in , he should not be able to goto login page again using back button of browser.
Does page reloads fresh when back button is clicked or it simply displays what was earlier.

login.jsp

<%
response.setHeader("Cache-Control","max-age=0");
response.setHeader("Pragma","no-cache");
response.setDateHeader("Expires", 0); //prevents caching at the proxy server
%>
<script type="text/javascript">
alert("hi");
</script>
<HTML>
<HEAD> 
</HEAD> 
<BODY>
my page body
<form action="validation.jsp">
<input type="submit">
</form>
</BODY>
</HTML>

If user clicks back button of browser , alert("hi") is not executed.it means it simply display the last page.

How can i prevent this.
Thanx in advance

Read a cookie in login page, Redirect the user if cookies is found. If cookie is not found then allows user to submit username, andpassword. Once, user is authenticated by your system then create a cookie.

Ehmm why to mess with cookies when you can use power of session?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.