lock lock - 10 months ago 79
C# Question

how to delete cookies in asp.net website

In my website when user clicks on logout button. Logout.aspx page loads with code

; in ASP.NET/C# do this clear all cookies? Or is there any other code to be added to remove all the cookies of my website?

Answer Source

Try something like that:

if (Request.Cookies["userId"] != null)
    Response.Cookies["userId"].Expires = DateTime.Now.AddDays(-1);   

But it also makes sense to use


besides in many scenarios.