Delete cookie in asp.net core
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vishal YelveRank #178 · 13.6K reputationPosted Nov 12, 2022, 2:03 PM EST
if (Request.Cookies["UserSettings"] != null) { HttpCookie myCookie = new HttpCookie("UserSettings"); //Here, we are setting the time to a previous time. //When the browser detect it next time, it will be deleted automatically. myCookie.Expires = DateTime.Now.AddDays(-1d); Response.Cookies.Add(myCookie); }