Skip to content

Commit e2e689a

Browse files
authored
Ensuring deleted cookies are recognized by the browser by ensuring the MaxAge within CookieOptions is set to null. (#55169)
* Explicitly appending the MaxAge as null at the end of the delete method to ensure deletion within the browser * Ensuring the IsEssential property of CookieOptions is carried * syntax error. * Simplifying the change to just override MaxAge and Expires when appending * Adding insightful comment to ResponseCookies.cs * Ammending the methods DeleteCookie() and DeleteChunks() to ensure MaxAge of cookieOptions is set to null upon deletion
1 parent c9af79a commit e2e689a

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

src/Http/Http/src/Internal/ResponseCookies.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public void Delete(string key, CookieOptions options)
163163
Append(key, string.Empty, new CookieOptions(options)
164164
{
165165
Expires = DateTimeOffset.UnixEpoch,
166+
MaxAge = null, // Some browsers require this (https://github.com/dotnet/aspnetcore/issues/52159)
166167
});
167168
}
168169

src/Shared/ChunkingCookieManager/ChunkingCookieManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options)
304304
responseCookies.Append(keyValuePairs, new CookieOptions(options)
305305
{
306306
Expires = DateTimeOffset.UnixEpoch,
307+
MaxAge = null, // Some browsers require this (https://github.com/dotnet/aspnetcore/issues/52159)
307308
});
308309
}
309310

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

0 commit comments

Comments
 (0)