HeaderDial › Guides

Why was my cookie blocked? Paste the warning, get the fix

Paste the cookie warning from Chrome or Edge DevTools (This attempt to set a cookie via a Set-Cookie header was blocked because…) or from the Firefox console (Cookie “sid” rejected because…), the Set-Cookie line from the response headers, or both. Add the page's URL and the API's URL and the page also checks the line itself: same site or not, SameSite, Secure, Domain, Path, prefixes and size. You get the cause, the corrected Set-Cookie line, code for Express, PHP, Django or nginx, and a HeaderDial profile to try the fix in your own browser. Everything runs in this page: it makes no network requests after it has loaded, and nothing you paste is sent anywhere.

Examples:

Read locally. Nothing you paste leaves this tab.

Your own sites only. SameSite, Secure and third-party blocking protect users from cross-site tracking and request forgery. Loosen them only for cookies your app needs across sites, and keep HttpOnly on session cookies. The browser profile is for testing; it changes responses in your browser alone.

Where to find the message

Same site or not? The rule behind most cookie problems

SameSite is about sites, not origins. A site is the scheme plus the registrable domain (the part you buy: example.com, example.co.uk). Ports and subdomains do not matter.

PageCookie URLSame site?
http://localhost:5173http://localhost:8080Yes: ports do not count
https://app.example.comhttps://api.example.comYes (but a different origin, so fetch still needs credentials: 'include')
http://localhost:3000http://127.0.0.1:8000No: different hosts
https://shop.vercel.apphttps://shop-api.vercel.appNo: vercel.app is a public suffix, like netlify.app, herokuapp.com, github.io, pages.dev and onrender.com
http://localhost:5173https://api.example.comNo, and the cookie is third-party
http://example.comhttps://example.comNo in Chrome and Edge (they compare schemes too)

When the page and the API are different sites, the cookie needs SameSite=None; Secure, which needs https on the API. Firefox 158 is more lenient here than Chrome: it stores a cross-site cookie without SameSite (in a separate jar per top-level site), so code that works in Firefox can still fail in Chrome. The simplest fix is often to make them the same site: serve the API under the app's domain (api.example.com next to app.example.com), or call it through the dev server's proxy (Vite server.proxy, Next.js rewrites) so the browser only ever sees the page's own origin.

Every cause the explainer knows

The texts below were captured in Chrome 159 and Firefox 158 (two runs each, identical; page on https://a.test, API on https://b.test). Chrome's are the DevTools Network-panel tooltips; Firefox's are console lines, with your cookie's name in place of sid. "Nothing" means the browser showed no reason anywhere we could read.

CauseChrome / Edge DevToolsFirefox consoleFix
SameSite=None without Secure…blocked because it had the "SameSite=None" attribute but didn’t have the "Secure" attribute…Cookie “sid” rejected because it has the “SameSite=None” attribute but is missing the “secure” attribute.Add Secure; serve the API over https
No SameSite, set by a cross-site fetchThis "Set-Cookie" header didn’t specify a "SameSite" attribute and was defaulted to "SameSite=Lax"…Stored (partitioned); only …will soon be rejected because it is foreign and does not have the “Partitioned“ attribute.SameSite=None; Secure
SameSite=Strict or Lax, set cross-site…had the "SameSite=Strict" attribute but came from a cross-site response which wasn’t the response to a top-level navigationCookie “sid” has been rejected because it is in a cross-site context and its “SameSite” is “Lax” or “Strict”.SameSite=None; Secure, or make it same-site
Lax cookie not sent on a cross-site fetchThis cookie was blocked because it had the "SameSite=Lax" attribute and the request was made from a different site…Nothing (not sent)Same as above
Strict cookie not sent after a link from another site…had the "SameSite=Strict" attribute and the request was made from a different site. This includes top-level navigation requests…Nothing (not sent; a Lax cookie was sent)SameSite=Lax if links from other sites must arrive logged in
Secure from an http response…had the "Secure" attribute but wasn’t received over a secure connection…rejected because a non-HTTPS cookie can’t be set as “secure”.https, or http://localhost (accepted: our test stored a Secure cookie there in Chrome 159)
http page replacing a Secure cookie…wasn’t sent over a secure connection and would have overwritten a cookie with the "Secure" attribute…rejected because there is an existing “secure” cookie.Use https, or another name
Domain not covering the host…its "Domain" attribute was invalid with regards to the current host URLCookie “sid” has been rejected for invalid domain.Remove Domain or use a parent domain of the host
__Host- / __Secure- rules…it used the "__Secure-" or "__Host-" prefix in its name and broke the additional rules……has been rejected for invalid prefix.Secure; for __Host- also Path=/, no Domain
Over 4096 bytes…the cookie was too large. The combined size of the name and value must be less than or equal to 4096 characters.…is invalid because its size is too big. Max size is 4096 B.Store an id, keep the data on the server
Partitioned without SecureNothing (dropped silently)…has the “Partitioned” attribute but is missing the “secure” attribute.Add Secure
Control character in the valueThis "Set-Cookie" header contained a disallowed character……has been rejected for invalid characters in the value.Encode the value
Third-party cookies blocked…was blocked due to user preferences (Chrome allowed them by default in our tests)…has been rejected as third-party. with strict tracking protection; by default Firefox partitions them insteadNot a header problem: put the API on the page's site, or use Partitioned

Not captured: Safari, which shows no reason. Silent in both browsers: Max-Age=0 or a past Expires (the cookie is deleted), and document.cookie trying to replace an HttpOnly cookie (ignored).

When nothing is logged at all

Why test the fix in the browser first

Cookie fixes are deploy-and-retry work: change the attributes, deploy, log in again, look in DevTools. A HeaderDial profile adds the corrected Set-Cookie line to the API's responses in your own browser, so you can check that the rest of the flow works (the cookie is stored, then sent, and the API accepts it) before you change the server. A Send row goes further and adds name=value to requests directly, which tells you whether the backend works once the cookie arrives. The profile needs site access to the API's host. Its Set-Cookie line follows the same rules as the server's: SameSite=None; Secure still needs https. More in send a cookie with requests and test with Cookie and Set-Cookie headers.

How the page works

It matches the pasted text against the cookie messages Chrome, Edge and Firefox show in English and reads the cookie name where the message has one (Firefox's always do; Chrome's tooltips do not). Set-Cookie lines are parsed and checked against the URLs you enter: the site of each (with a built-in list of common public suffixes such as co.uk and vercel.app, not the full Public Suffix List), whether the cookie URL is https or localhost, whether Domain covers the host, and the default path. The corrected line keeps your attributes and changes only what the causes need.

Add to ChromeFirefox: coming soon