Debug guide · you're seeing
This attempt to set a cookie via a Set-Cookie header was blocked because it had the "SameSite=None" attribute but did not have the "Secure" attribute, which is required in order to use "SameSite=None".This cookie was blocked because it had the "SameSite=Lax" attribute and the request was made from a different site and was not initiated by a top-level navigation.Cookie “session” has been rejected because it is in a cross-site context and its “SameSite” is “Lax” or “Strict”.
Why Is My Cookie Not Being Sent?
On this page
TL;DR: A missing
Cookieheader means the browser rejected the cookie when it was set, decided the request is outside the cookie’s scope, or withheld credentials. Check in order: was it stored, do Domain, Path and Secure match the URL, is the request cross-site for SameSite, and does a cross-originfetchsendcredentials: 'include'?
1. Confirm the browser stored the cookie
Start with the response that creates the cookie. In DevTools, open Network, select that response and read its Set-Cookie header, then look in the Application (Chrome) or Storage (Firefox) panel. A cookie that never reached the cookie store cannot appear on a later request.
curl -i https://api.example.com/session
HTTP/2 200
Set-Cookie: session=abc123; Path=/; Secure; HttpOnly; SameSite=Lax
Browsers show a warning next to a rejected Set-Cookie header. Common reasons are an invalid Domain, SameSite=None without Secure, a malformed attribute, or a third-party cookie policy.
2. Match Domain, Path and Secure to the request URL
A stored cookie is sent only when every scope rule matches the destination URL:
- Domain: a host-only cookie set by
api.example.comis not sent towww.example.com. A validDomain=example.comcookie covers subdomains. - Path:
Path=/accountmatches/account/profilebut not/api/profile. - Secure: a
Securecookie is sent only over HTTPS. Browsers special-caselocalhostduring development, so test production behavior over HTTPS.
Do not widen Domain or Path just to make a test pass. Use the narrowest scope that covers the endpoints that need the cookie.
3. Determine whether the request is cross-site
SameSite compares the registrable site and scheme, not the full origin. app.example.com and api.example.com are cross-origin but same-site; a request from a page on customer.example to api.example.com is cross-site.
| SameSite value | Typical behavior |
|---|---|
Strict | Withheld on every cross-site request, including top-level navigations |
Lax (Chrome treats unset as Lax) | Withheld on cross-site subrequests, sent on top-level GET navigations |
None; Secure | Eligible for cross-site use, subject to the browser’s third-party cookie policy |
4. Include credentials on cross-origin fetch requests
fetch uses same-origin credentials by default. When the API is on another origin, opt in:
const response = await fetch('https://api.example.com/me', {
credentials: 'include'
})
The API response must allow it:
Access-Control-Allow-Origin: https://app.example.com
Access-Control-Allow-Credentials: true
Vary: Origin
Credentialed requests cannot use Access-Control-Allow-Origin: *. When the request needs a preflight, the preflight and the actual response must both pass. The CORS Debugger and the failed preflight checklist isolate that part.
5. Check lifetime, prefixes and browser policy
Expiresmust be in the future andMax-Agegreater than zero.__Host-cookies needSecure, noDomainattribute andPath=/.__Secure-cookies needSecureand must be set from an HTTPS page.- Private browsing, storage limits, user settings and third-party cookie restrictions can reject or partition cookies.
- A proxy or framework can rewrite or drop
Set-Cookie. Compare the origin’s response with what reaches the browser.
Once you find the rule that fails, generate a corrected header with the Set-Cookie Builder and verify it in a fresh browser session.
Frequently asked questions
Why is a cookie visible in DevTools but absent from the request?
The cookie is stored but out of scope for that request. Check its Domain, Path, Secure, SameSite and expiry, and whether the browser treats the request as third-party.
Does fetch send cookies automatically?
Only to the same origin by default. For a cross-origin request, set credentials to include. The server must also allow credentials and return the exact allowed origin rather than a wildcard.
Why does SameSite=None still fail?
SameSite=None cookies must also be Secure, and Secure cookies need HTTPS (browsers special-case localhost). Third-party cookie restrictions can still block or partition them.
Sources
Related
Domain
Learn how the Domain cookie attribute controls which domains can access cookies. Understand subdomain sharing, security implications, and restrictions.
SameSite Cookie Attribute: Strict, Lax and None
How SameSite works: Strict, Lax and None, what counts as same-site, why Lax-by-default is Chromium behavior, and how to fix cookies blocked cross-site.
Cookie Security: HttpOnly, SameSite, and Secure Flags
A comprehensive guide to understanding and implementing secure HTTP cookies to protect against XSS, CSRF, and session hijacking attacks.
Set-Cookie Header: Attributes, Examples and Browser Rules
Set-Cookie syntax and every attribute: Expires, Max-Age, Domain, Path, Secure, HttpOnly, SameSite, Partitioned, __Host- prefixes, with Express and Django.