Home / Knowledge hub / SameSite cookie
Knowledge hub
SameSite cookie
A cookie setting that limits when a browser sends it on requests from other sites.
What it means
SameSite is an attribute on a cookie that controls whether the browser sends it along with requests that start on a different site. It has three values. Strict never sends it cross-site. Lax sends it only on top-level navigations that use safe methods such as GET. None sends it everywhere, and must be paired with Secure.
Its main purpose is to blunt cross-site request forgery. If the session cookie is not sent when another site triggers a form post, the forged request arrives without a session and fails. It is a cheap, useful default, set in one header.
Why it matters
It closes a whole family of attacks with one attribute, and costs nothing if set early. It also protects some cross-site data leaks. Left unset, an app depends on whatever the visitor's browser decides, and that differs between browsers and versions.
It is not a complete answer. A site is not an origin: subdomains of the same registrable domain count as the same site, so a flaw on any one of them can still send authenticated requests. OWASP treats SameSite as defence in depth alongside CSRF tokens.
How it shows up
Most frameworks set SameSite on the session cookie for you, often to Lax. Chromium-based browsers treat a cookie without the attribute as Lax, but other browsers differ, so set it explicitly. Use Strict for cookies that guard high-value actions, and None only when a cookie truly must travel cross-site, for example in an embedded widget.
The mistakes: None used to "fix" a login redirect without understanding why, then left in place; Lax assumed to cover state changes made with GET; and a long-lived cookie shared with a loosely maintained subdomain. Check each cookie's attributes in the response headers, and remember cookie scope matters too.
Questions people ask
SameSite cookie, answered
What is the difference between Strict and Lax?
Strict withholds the cookie on every cross-site request, including when a user clicks a link from another site, so they may appear signed out on arrival. Lax allows the cookie on top-level GET navigations, so links work.
Lax is the usual choice for session cookies.
Does SameSite replace CSRF tokens?
No. It is a useful extra layer, but its handling depends on the browser, and subdomains of the same site are not blocked. Anyone who can make a request from a sibling subdomain can still get the cookie sent.
Use tokens for state-changing requests as well.
What does SameSite=None require?
Browsers that honour the rule require the Secure attribute alongside None, so the cookie is only sent over HTTPS. Without it, the cookie is rejected.
Only use None where a cross-site cookie is a real need, such as an embedded service.
Is same-site the same as same-origin?
No. Same-origin means identical scheme, host and port. Same-site means the same registrable domain and scheme, so app.example.com and www.example.com are same-site but not same-origin. The two ideas are easy to mix up.
See same-origin policy.
How do we check our cookies?
Look at the Set-Cookie headers in the browser developer tools or with a proxy, and read the attributes on each cookie. Test a cross-site form post and see whether the cookie is sent.
Session cookies without SameSite are worth fixing first.
Related
Terms that sit next to this one
CSRF
An attacker's page makes a logged-in user's browser act on your site.
CSRF token
A secret value in each form that proves the request came from your own page.
Same-origin policy
The browser rule that stops one site's scripts reading another site's data.
Cookie scope
The domain and path settings that decide which sites and pages receive a cookie.
Secure cookie flag
A setting that makes the browser send a cookie only over HTTPS.
Which cookies travel across sites?
We check the cookies your app sets, then try cross-site requests to see whether a forged one is still accepted. We report only what worked, with the request and response. Book a pilot on one app.
Or start with a $199 pilot on one application: thirty days, success criteria agreed before day one, credited against the annual if you convert.