How to delete cookies on an ASP.NET website

后端 未结 11 1920
傲寒
傲寒 2020-11-30 05:07

In my website when the user clicks on the \"Logout\" button, the Logout.aspx page loads with code Session.Clear().

In ASP.NET/C#, does this clear all co

11条回答
  •  有刺的猬
    2020-11-30 05:49

    You have to set the expiration date to delete cookies

    Request.Cookies[yourCookie]?.Expires.Equals(DateTime.Now.AddYears(-1));
    

    This won't throw an exception if the cookie doesn't exist.

提交回复
热议问题