Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1115
  • Last Modified:

Prevent User From Going Back After Clicking Logout

Our client has pointed out to us recently that after a user clicks logout, they can still click the back button and see pages and information.  This is true.  If the user attempted to click on a link or refresh the page THEN, because they are logged out, they would be redirected to the login page.

Is there a way to prevent this behavior?  I don't want to block the back button.  I can't think of a way that will stop a page from showing when they are logged out but simply click the back button.  I have noticed however, that with my online bank account, if i click logout and then the back button it takes me straight to a login page.
0
davidcahan
Asked:
davidcahan
  • 2
1 Solution
 
sm394Commented:
see if that could help

http://forums.asp.net/t/1132444.aspx
0
 
sm394Commented:
this is c#
version


    protected void lbLogout_Click(object sender, EventArgs e)
    {
        Session.Clear();
 
        string nextpage = "Login.aspx";
        Response.Write("<SCRIPT LANGUAGE=javascript>");
 
        Response.Write("{");
        Response.Write(" var Backlen=history.length;");
 
        Response.Write(" history.go(-Backlen);");
        Response.Write(" window.location.href='" + nextpage + "'; ");
 
        Response.Write("}");
        Response.Write("</SCRIPT>");
 
        
    }

Open in new window

0
 
davidcahanAuthor Commented:
that didn't work for me.  However, I did some research and found that as long as I don't cache the pages then a user can't get to any private data after they logout and then hit the back button.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now