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

Add configurable SameSite cookie option #170

Merged
merged 1 commit into from
May 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Microsoft.AspNetCore.Session/SessionMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ private void SetCookie()
var cookieOptions = new CookieOptions
{
Domain = _options.CookieDomain,
SameSite = _options.SameSiteMode,
HttpOnly = _options.CookieHttpOnly,
Path = _options.CookiePath ?? SessionDefaults.CookiePath,
};
Expand Down
6 changes: 6 additions & 0 deletions src/Microsoft.AspNetCore.Session/SessionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public class SessionOptions
/// </summary>
public bool CookieHttpOnly { get; set; } = true;

/// <summary>
/// Determines if the browser should allow the cookie to be attached to same-site or cross-site requests. The
/// default is Lax, which means the cookie is allowed to be attached to same-site and safe cross-site requests.
/// </summary>
public SameSiteMode SameSiteMode { get; set; } = SameSiteMode.Lax;

/// <summary>
/// Determines if the cookie should only be transmitted on HTTPS requests.
/// </summary>
Expand Down