0
votes

I've created a log in and log out page for the user, but the problem is that when the user logs out from the site and it again clicks on the back button of the browser he/she is able to view the site again without being logged in. So I want to restrict the user to being able to view the site after being logged out from the page.

Please just look at my code and tell me where I need a change

I've used code for the back button to restricts user.

<script type="text/javascript">
    function preventBack() {
        alert();
        console.log("hello");
        window.history.forward();
    }
    setTimeout("preventBack()", 100);
    window.onunload = function () {
        null
    };
</script>
2
you have session?you can use itguradio
yes , I have session and after the login i have cleared session but still i am going to back page , I want to restrict it.kamesh pathak

2 Answers

0
votes

On Page_Load event write below code:

If(Session["SessionName"]==null)
{
    Response.Redirect("LoginPagename.aspx");
}
0
votes

your using session so while logout time inside logout function clear the session then redirect to your login page else you can disable back button.