Skip to content

Ensuring deleted cookies are recognized by the browser by ensuring the MaxAge within CookieOptions is set to null. #55169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 19, 2024
Merged
1 change: 1 addition & 0 deletions src/Http/Http/src/Internal/ResponseCookies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public void Delete(string key, CookieOptions options)
Append(key, string.Empty, new CookieOptions(options)
{
Expires = DateTimeOffset.UnixEpoch,
MaxAge = null, // Some browsers require this (https://github.com/dotnet/aspnetcore/issues/52159)
});
}

Expand Down
2 changes: 2 additions & 0 deletions src/Shared/ChunkingCookieManager/ChunkingCookieManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options)
responseCookies.Append(keyValuePairs, new CookieOptions(options)
{
Expires = DateTimeOffset.UnixEpoch,
MaxAge = null, // Some browsers require this (https://github.com/dotnet/aspnetcore/issues/52159)
});
}

Expand Down Expand Up @@ -331,6 +332,7 @@ private static void DeleteChunks(HttpContext context, IRequestCookieCollection r
context.Response.Cookies.Append(keyValuePairs.ToArray(), new CookieOptions(options)
{
Expires = DateTimeOffset.UnixEpoch,
MaxAge = null, // Some browsers require this (https://github.com/dotnet/aspnetcore/issues/52159)
});
}
}
Expand Down
Loading