How HTTP Works

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?

Reviewed 2 min readintermediate3 sourcesTry itMarkdown
On this page

TL;DR: A missing Cookie header 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-origin fetch send credentials: 'include'?

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.com is not sent to www.example.com. A valid Domain=example.com cookie covers subdomains.
  • Path: Path=/account matches /account/profile but not /api/profile.
  • Secure: a Secure cookie is sent only over HTTPS. Browsers special-case localhost during 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 valueTypical behavior
StrictWithheld 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; SecureEligible 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

  • Expires must be in the future and Max-Age greater than zero.
  • __Host- cookies need Secure, no Domain attribute and Path=/.
  • __Secure- cookies need Secure and 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

  1. IETF draft: HTTP State Management Mechanism (RFC 6265bis)httpwg.org
  2. WHATWG Fetch: credentialsfetch.spec.whatwg.org
  3. MDN: Third-party cookiesdeveloper.mozilla.org

Keep going

Browse /search