lock lock - 1 year ago 99
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download