Skip to content
This repository was archived by the owner on Nov 22, 2018. It is now read-only.

Commit b899775

Browse files
committed
Add configurable SameSite cookie option
1 parent 87d063b commit b899775

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/Microsoft.AspNetCore.Session/SessionMiddleware.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ private void SetCookie()
153153
var cookieOptions = new CookieOptions
154154
{
155155
Domain = _options.CookieDomain,
156+
SameSite = _options.SameSiteMode,
156157
HttpOnly = _options.CookieHttpOnly,
157158
Path = _options.CookiePath ?? SessionDefaults.CookiePath,
158159
};

src/Microsoft.AspNetCore.Session/SessionOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public class SessionOptions
3636
/// </summary>
3737
public bool CookieHttpOnly { get; set; } = true;
3838

39+
/// <summary>
40+
/// Determines if the browser should allow the cookie to be attached to same-site or cross-site requests. The
41+
/// default is Lax, which means the cookie is allowed to be attached to same-site and safe cross-site requests.
42+
/// </summary>
43+
public SameSiteMode SameSiteMode { get; set; } = SameSiteMode.Lax;
44+
3945
/// <summary>
4046
/// Determines if the cookie should only be transmitted on HTTPS requests.
4147
/// </summary>

0 commit comments

Comments
 (0)