i've review the latest logout and cannot back if BACK button is press..
anyone can help me in clearly how to code it?

new_SE Could you please be a bit more specific about what it is you're trying to do here? Your post is far from clear and therefor difficult to answer.

i'm trying to make a session end and the user cannot enter the system without login.. i had tried many ways but it still the same, user can enter the system after logout by hitting the back button.. for the login,i'm using session..
code for login

protected void Submit_Click(object sender, EventArgs e)
        SqlConnection conn = new SqlConnection("Server=(local); Database=test; user id=sa;  password=");
        SqlCommand cmd;
        string cmdstring = "SELECT [password] FROM [Customers] WHERE" + " [username]=@username and [password]=@password";
        cmd = new SqlCommand(cmdstring, conn);
        cmd.Parameters.Add("@username", SqlDbType.NVarChar, 50);
        cmd.Parameters["@username"].Value = txtUserName.Text;
        cmd.Parameters.Add("@password", SqlDbType.NVarChar, 50);
        cmd.Parameters["@password"].Value = txtPassword.Text;

        SqlDataReader reader;
        reader = cmd.ExecuteReader();
        if (reader.Read())
            Session["username"] = txtUserName.Text;
            // FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false);
            Response.Write("Invalid Login!!");

for the logout, now i just have this:

Session["username"] = "null";

i dont what else should i put..

My friend i already suggested clear the cache of the page, do some googling man.

your problem is because your page once served from server gets cached at client End.

i.e the reason why after you hit the logout button, it will not call the page events.

but instead it will draws the page from the cache.

after clearing the cache, now when you hit the back button.

page will be requested from server and all the events will be executed and

user will get redirected to login page automatically if u r using the


hope that helps.




You can refer following code for back and logout.

<a href="logout.jsp" target="_new" onclick="location.replace('browserClose.php');">Logout</a>