469,621 Members | 1,688 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,621 developers. It's quick & easy.

problem in browser back button with logout

in my project when i click on logout anchor it goes to logout page and my code in logout page is
Expand|Select|Wrap|Line Numbers
  1.  if (Session["user_id"] != null)
  2.         {
  3.             Session["user_id"] = null;
  4.             Session.Abandon();
  5.             Response.Clear();
  6.             FormsAuthentication.SignOut();
  7.             Response.Redirect("login.aspx");
  8.         }
it properly logout and goes to login.aspx but problem is login.aspx when i click browser back button it goes me again on last page where i click on logout anchor.
please any body know solution of this please reply me
Aug 17 '08 #1
4 3151
Curtis Rutland
3,256 Expert 2GB
When you click the back button the browser is loading from it's cache, not the internet.

I'm not sure what your question is...
Aug 17 '08 #2
my question is when user click on back button after logout, he can't go again in the previous page
Aug 19 '08 #3

Add the above code in the page where clearing the session

Ex: Add the code in page 1, click logout takes u to Page 2

Now if u click on back button in page 2, u cannot come back to Page 1
Aug 22 '08 #4
7,872 Expert 4TB
This question comes up at least 2 times a week it seems.
You should be doing the following on every page (or at least every page you don't want the user to be able to use the back button on):
-Set the Caching on the Response object to not cache
-Validate the Session contents
Aug 22 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Bartosz Wegrzyn | last post: by
3 posts views Thread by Lord2702 | last post: by
5 posts views Thread by guy | last post: by
25 posts views Thread by Jonno | last post: by
1 post views Thread by shrik | last post: by
2 posts views Thread by swethak | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.