problem in browser back button with logout

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shahidrasul
    New Member
    • Aug 2008
    • 18

    problem in browser back button with logout

    hi
    in my project when i click on logout anchor it goes to logout page and my code in logout page is
    Code:
     if (Session["user_id"] != null)
            {
                Session["user_id"] = null;
                Session.Abandon();
                Response.Clear();
                FormsAuthentication.SignOut();
                Response.Redirect("login.aspx");
            }
    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
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    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...

    Comment

    • shahidrasul
      New Member
      • Aug 2008
      • 18

      #3
      my question is when user click on back button after logout, he can't go again in the previous page

      Comment

      • yvrmurari
        New Member
        • Aug 2008
        • 4

        #4
        <Script>
        window.history. forward(1);
        </Script>

        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

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          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

          Comment

          Working...