Phani Kumar

Phani Kumar

  • NA
  • 162
  • 24.8k

how to clear browser cookies for user credentials

Jun 10 2020 8:25 AM
Hi Team,
 
I have a requirement, user can login to website from any browser and clikced on remember me after performing his/her work, user will logout, once logged out cookies should be cleared automatically, I have tried by adding below code.
 
Session.Clear();
Session.Abandon();
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
HttpContext.Current.Response.Cache.SetValidUntilExpires(false);
HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetNoStore();
HttpContext.Current.Response.Cookies.Clear();
HttpContext.Current.Request.Cookies.Clear();
 
 
FormsAuthentication.SignOut();
Response.Clear();
FormsAuthentication.RedirectToLoginPage("loginpageurl");
 
This code was added in my logout page and tried it, but it couldn't worked
 
Can anyone help me out on this. 
 
Thanks in advance for help
 
 
Regards
Phani Kumar 
 

Answers (2)