SameSite

SameSite is a Set-Cookie attribute that controls if the browser sends a cookie with cross-site requests. It has three values, Strict, Lax, and None.

Cookie attribute

Updated

On this page

How it works

The browser compares the site of the request URL with the site of the top page. A site is the scheme plus the registrable domain, for example https://example.com. If the two sites are different, the request is cross-site, and SameSite decides if the cookie goes with it.

A frame from https://widget.example on https://shop.example is cross-site. Its requests to widget.example carry only the cookies with SameSite=None. This also helps against clickjacking, because a page in a frame on another site often shows the visitor as signed out.

Values

ValueWhen the browser sends the cookie
StrictOnly with requests from the same site
LaxSame-site requests, and top-level navigations with a safe method like GET
NoneAll requests, same-site and cross-site. Needs Secure
Not setSome browsers, such as Chrome, use Lax

When a browser uses Lax as the default, it is less strict. It also sends the cookie with a cross-site POST if the cookie is less than two minutes old.

Example

HTTP response header
Set-Cookie: session=abc123; Path=/; Secure; HttpOnly; SameSite=None

Without Secure, the browser ignores a cookie with SameSite=None.

How to set it

Use Lax or Strict for a cookie that only your own site needs. Use None with Secure for a cookie that a cross-site iframe needs.

# Only your own site
Set-Cookie: session=abc123; Path=/; Secure; HttpOnly; SameSite=Lax

# Also in a cross-site iframe
Set-Cookie: session=abc123; Path=/; Secure; HttpOnly; SameSite=None

SameSite=None does not get past third-party cookie blocking. Safari can still block the cookie.

Learn more

Sources

Know before you embed.

Free, no sign-up, nothing stored. Paste a URL and get a verdict, a live preview, and the fix.