How to control back button in browser

Reply

Join Date: Jun 2009
Posts: 9
Reputation: gshockneo is an unknown quantity at this point 
Solved Threads: 0
gshockneo gshockneo is offline Offline
Newbie Poster

How to control back button in browser

 
0
  #1
Jul 8th, 2009
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
  1. <%
  2. response.setHeader("Cache-Control","max-age=0");
  3. response.setHeader("Pragma","no-cache");
  4. response.setDateHeader("Expires", 0); //prevents caching at the proxy server
  5. %>
  6. <script type="text/javascript">
  7. alert("hi");
  8. </script>
  9. <HTML>
  10. <HEAD>
  11. </HEAD>
  12. <BODY>
  13. my page body
  14. <form action="validation.jsp">
  15. <input type="submit">
  16. </form>
  17. </BODY>
  18. </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
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,562
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 454
Moderator
adatapost's Avatar
adatapost adatapost is offline Offline
Posting Maven

Re: How to control back button in browser

 
0
  #2
Jul 9th, 2009
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.
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,179
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 481
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: How to control back button in browser

 
0
  #3
Jul 9th, 2009
Ehmm why to mess with cookies when you can use power of session?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC