Click here to Skip to main content
15,884,986 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
every think is running fine but when use logout from my site then they press back button of browser that time privios page of website seen...


i have done website in asp.net with c#...

now what i do 4 it.. so after logout ,no one can see privios page of website..
Posted
Comments
Sinisa Hajnal 18-Sep-14 7:58am    
How do you control if someone is logged on? Do you store a user token in the session? Use Form Authentication and rely on AuthProvider? If it is session based, you have to call Session.Clear or even Session.Abandon. More details, please.
[no name] 19-Sep-14 8:23am    
i user cookie to store username and user postion.. and i check this cookie on page load on every page

 
Share this answer
 
Comments
[no name] 19-Sep-14 8:27am    
Great post bro.... thank u very much Khem thapa
try this

C#
page_load()
{
    if(Session["userLogged"]=="") // check for the session
    {
        response.redirect("loginpage")
    }
}
 
Share this answer
 
v2
XML
<script type="text/javascript">
    function preventBack() { window.history.forward(); }
    setTimeout("preventBack()", 0);
    window.onunload = function () { null; };
</script>

Use this on the Login page to prevent the history forward. And on the Hime page place the below snippet:
XML
<script type="text/javascript" language="javascript">
    function DisableBackButton() {
        window.history.forward();
    }
    DisableBackButton();
    window.onload = DisableBackButton;
    window.onpageshow = function (evt) { if (evt.persisted) DisableBackButton(); }
    window.onunload = function () { void (0); };
</script>

Hope this helps.
Thank you :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900