Skip to content

Commit b6b5319

Browse files
martincostelloTratcher
authored andcommitted
Use UnixEpoch for cookie deletion (#18126)
Use the DateTimeOffset.UnixEpoch field instead of a new DateTime value when deleting cookies.
1 parent c802134 commit b6b5319

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void Delete(string key, CookieOptions options)
129129
{
130130
Path = options.Path,
131131
Domain = options.Domain,
132-
Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc),
132+
Expires = DateTimeOffset.UnixEpoch,
133133
Secure = options.Secure,
134134
HttpOnly = options.HttpOnly,
135135
SameSite = options.SameSite

src/Shared/ChunkingCookieManager/ChunkingCookieManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options)
288288
SameSite = options.SameSite,
289289
Secure = options.Secure,
290290
IsEssential = options.IsEssential,
291-
Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc),
291+
Expires = DateTimeOffset.UnixEpoch,
292292
HttpOnly = options.HttpOnly,
293293
});
294294

@@ -305,7 +305,7 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options)
305305
SameSite = options.SameSite,
306306
Secure = options.Secure,
307307
IsEssential = options.IsEssential,
308-
Expires = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc),
308+
Expires = DateTimeOffset.UnixEpoch,
309309
HttpOnly = options.HttpOnly,
310310
});
311311
}

0 commit comments

Comments
 (0)