I was facing a problem during one of my project. Actually, I was developing an E-Commerce site, in which I need to give login and logout button. I did login part easily and logout also. But problem arisen, when I pushed back button. Oh! God! Even after logout, it creates a session without login. How? I put all code behind ‘Logout’ button. But still I was facing the problem. We saw many codes, tried a lot of way to logout but still back button is not disabled.
So, here I am writing the proper code, which we finally found out and happy news is that, “It really works!”. So just follow this code.
If you applying a MasterPage, then copy these codes to its page load, or copy to that page’s load, which comes after login page or comes before logout page.
Place below code in master page ‘s page load event
Place below code on logout
Session[“Admin”] = null;