How to disable the back functionality of the browser after we log out. Or any other mechanism to restrict the user to view recently visited pages (when he clicks the back button of the browser)

Showing Answers 1 - 23 of 23 Answers

Shruthi Hatti

  • Jan 25th, 2006
 

One of the best Method is Kill the session using Session.Abondon(); once user is logged out.If any other solution pls post it....Happy Learning:)All the Best

  Was this answer useful?  Yes

samiksc

  • Jan 25th, 2006
 

Another way is to write a javascript function which reads value of a hidden field, say isLoggedIn, and if found false, forwards the page by using window.history.forward(1), so that the effect of the back button is reset.

The isLoggedIn hidden field will be set to true or 1 when the user logs in and it will be set to false or 0 when a user logs out.

This script should be incorporated in the header of every aspx page and every page should have a hidden field like isLoggedIn.

  Was this answer useful?  Yes

imran

  • Feb 28th, 2006
 

both of solutions are good.

1st one is more suitable , as you are already using session . and if session expired adn user requested for back button he/she will be redirected to login page.

problem in javascripting is that you need to use it on every page

  Was this answer useful?  Yes

vishal sharma

  • Mar 2nd, 2006
 

can anyone send that code to me as i am didnot getting that exactly how to disable the back funcationality of the brwoser when a user is logout.

i used that session.abandon also but all in vain

please help me

  Was this answer useful?  Yes

mahesh

  • Mar 16th, 2006
 

thanks for providing developer friendly site

  Was this answer useful?  Yes

Sagar

  • Mar 16th, 2006
 

you can also use form based authentication.

  Was this answer useful?  Yes

Balram R

  • Mar 25th, 2006
 

HI Friend ,

I thnk the back button can be disable by just puttiong following code.What it wwill do is it will disable the back button and show only the forward button ,so that user can move forward only.

regards

Balram R

(Balu)

  Was this answer useful?  Yes

Balram R

  • Mar 25th, 2006
 

HI Friend,

Sorry ! I forget to write the code....

Put this Code between <head></head> tag

The code is

<script language="javascript">

history.forward();

</script>

Regards

Balram R

(balu)

  Was this answer useful?  Yes

payal mangla

  • Mar 27th, 2006
 

 hello,

we are using php  & we want to disable the back button so that the user will be unable to see the recently visited pages.

Tell us the solution(except sessions).

  Was this answer useful?  Yes

Prasanta Sahoo

  • Mar 29th, 2006
 

Hi,

I am trying to disable Back Button in Mozilla browser. The code is working fine with IE, but not in Mozilla.

Please advise.

<html>
<head>
  <meta http-equiv="Expires" CONTENT="0">
  <meta http-equiv="Cache-Control" CONTENT="no-cache">
  <meta http-equiv="Pragma" CONTENT="no-cache">
</head>
<Script>
  window.history.forward(1);
</Script>

<a href="second.html" target="_blank" rel="nofollow"> first link </a>


</html>

thanks,

Prasanta

  Was this answer useful?  Yes

ramkim

  • Apr 5th, 2006
 

ASP.NET users can try this code and php users can convert this

In logout page embed this on page load event

Session.Aandon()

Dim strURL as string= "login.aspx"

Response.Write("<script language='javascript'>")

Response.Write(" window.open('" & strURL & "','_self','toolbar=1,<BR>location=1,directories=1,status=1,menubar=1,<BR>scrollbars=1,resizable=1'); ")

Response.Write("</script>")

  Was this answer useful?  Yes

sanju john

  • Feb 16th, 2007
 

Session.Abandon have no effect on the client side. If you want to disable a back button, you can write the javascript code in window_onunload, in submit_click event, write the code

document.form1.Text1.size = 19 (any value) (Suppose orgininal size is 20)

then in the onunload event of window,

if(document.form1.Text1.size != 19)

window.location = full path of your current page.

It is working fine in my page.If you have doubts, sanju1_john@rediffmail.com

 

  Was this answer useful?  Yes

ramya

  • Mar 2nd, 2007
 

<a herf="webform name" onclick="javascript:location.replace(this.href);event.returnValue=false;">no back page </a>
 

this works better
but there should not be any images on the page

  Was this answer useful?  Yes

Pradeep

  • Jul 23rd, 2007
 

Back functionality is working fine with the following code

window.history.forward(1);

But it is not working in the firefox..

  Was this answer useful?  Yes

bashaasen

  • Jul 11th, 2008
 

Response.CacheControl = "no-store"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1

Use It in ur page load event by bass

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions