0

I am designing a website where a user can login and when the logout button is hit, then it returns the login page. However, when the browser's back button is clicked, it simply just goes back to the page where the user is still logged in. I tried to put in these `Session.Clear(); Session.RemoveAll(); Session.Abandon();

but none of them work. How can I really logout?`

kisbovan93
  • 45
  • 10
  • You are logged out, the browser shows you the cached page. See [duplicate](http://stackoverflow.com/questions/2686946/asp-net-authentication-login-and-logout-with-browser-back-button). – CodeCaster Apr 15 '15 at 08:51
  • @CodeCaster Those answers didn't work for me, after adding these Session.Abandon(); FormsAuthentication.SignOut(); and even these to the already logged in pages: Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetNoStore(); dont work, still after hitting the back button, the browser shows the logged in page. Maybe I'm not doing something right during login? – kisbovan93 Apr 15 '15 at 09:04
  • Manually clear your browser cache or press Ctrl+F5 first. Your browser is still showing the cached version. The problem _is_ caching, not the logging out. – CodeCaster Apr 15 '15 at 09:13
  • @CodeCaster And can I clear the cache somehow in the code before or after hitting the logout button to prevent the browser from showing the logged in state? – kisbovan93 Apr 15 '15 at 09:17
  • No, you need to do that yourself, once, in the browsers on your development machine, as it's probably still got some cached version of the page somewhere. – CodeCaster Apr 15 '15 at 09:19
  • Add some javascript to your page which calls the server to check the login status via AJAX. force a refresh when it returns false – Ewan Apr 15 '15 at 11:14

0 Answers0