Clear all cookies in Asp.net Core
Request.Cookies
is a key-value collection where the Key is a cookie name. So
foreach (var cookie in Request.Cookies.Keys)
{
Response.Cookies.Delete(cookie);
}
See:
public abstract class HttpRequest
{
// Summary:
// /// Gets the collection of Cookies for this request. ///
//
// Returns:
// The collection of Cookies for this request.
public abstract IRequestCookieCollection Cookies { get; set; }
...
}
and IRequestCookieCollection is
public interface IRequestCookieCollection : IEnumerable<KeyValuePair<string, string>>, IEnumerable
Try this:
//ASP.NET Core
foreach (string cookie in myCookies)
{
Response.Cookies.Delete(cookie);
}