In ASP.NET, I have a small div for the account in every page. In the page load of every page, I check if a session called username is null. if it is, I put login in the div. else I write their name there and put a button to log out. the log out deletes the session and load the login div instead of the current div. it's all good but if I log out and then press the back button, it the div with the accounts name returns. how should I fix it? an example for my issue.
aspx:
<%=accountDiv %>
aspx.cs:
if(Session["username"] != null){
accountDiv = "<div>" + Session["username"].ToString() +
"<form method='post' onsubmit='return true'><input type='submit' name='logout'></form></div>"
}
else{
accountDiv = "<div>" +
"<form method='post' onsubmit='return true'>" +
"<input type='text' name='username'>" +
"<input type='submit' name='login'>" +
"</form></div>";
}
if(Request.Form["login"]!=null){
Session["username"] = Request.Form["username"];
accountDiv = (code that builds the div with the name as before)
}
if(Request.Form["logout"]!=null){
Session.RemoveAll();
accountDiv = (code that builds the div with the login as before)
}