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.
Read locally. Nothing you paste leaves this tab.
The corrected cookie
Test the fix in your browser first
A HeaderDial profile that adds the corrected Set-Cookie line to the responses from one host, so the browser stores the cookie as if the server already sent it. The value is the one you pasted; change it here if it has expired.
For an exact fix, also paste the Set-Cookie line: DevTools, Network, click the request, Headers, Response Headers.
HttpOnly on session cookies. The browser profile is for testing; it changes responses in your browser alone.Where to find the message
- Chrome and Edge: the console says nothing about cookies (none of our 15 test cases logged a line there). Open DevTools, Network, click the request that sets the cookie, then the Cookies tab. A refused cookie is highlighted under Response cookies; hover the ⓘ or the row for the reason and copy it. For cookies that were stored but not sent, tick show filtered out request cookies under Request cookies. The Issues panel shows a headline for only some causes: in our tests just one, Mark cross-site cookies as Secure to allow setting them in cross-site contexts for
SameSite=NonewithoutSecure. - Firefox: the Console logs one line per refused cookie when it is set, starting
Cookie “name”. When a stored cookie is not sent (SameSite on a cross-site request), it logs nothing. Network → the request → Cookies shows what was sent and received. - Safari: it logs no reason. Web Inspector → Storage → Cookies shows whether the cookie was stored. Safari blocks all third-party cookies, so a cookie set by another site than the page is refused there even with
SameSite=None; Secure. - The Set-Cookie line: Network → the request → Headers → Response Headers, or
curl -si https://api.example.com/login | grep -i set-cookie.
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.
| Page | Cookie URL | Same site? |
|---|---|---|
http://localhost:5173 | http://localhost:8080 | Yes: ports do not count |
https://app.example.com | https://api.example.com | Yes (but a different origin, so fetch still needs credentials: 'include') |
http://localhost:3000 | http://127.0.0.1:8000 | No: different hosts |
https://shop.vercel.app | https://shop-api.vercel.app | No: vercel.app is a public suffix, like netlify.app, herokuapp.com, github.io, pages.dev and onrender.com |
http://localhost:5173 | https://api.example.com | No, and the cookie is third-party |
http://example.com | https://example.com | No 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.
| Cause | Chrome / Edge DevTools | Firefox console | Fix |
|---|---|---|---|
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 fetch | This "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 navigation | Cookie “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 fetch | This 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 URL | Cookie “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 Secure | Nothing (dropped silently) | …has the “Partitioned” attribute but is missing the “secure” attribute. | Add Secure |
| Control character in the value | This "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 instead | Not 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
- The fetch does not include credentials. A request to another origin sends no cookies and ignores
Set-Cookieunless you writefetch(url, { credentials: 'include' })(axios:withCredentials: true). The API must answer withAccess-Control-Allow-Credentials: trueand your exact origin; the CORS error explainer covers those errors. - The Path is too narrow. Without
Path, a cookie set by/api/auth/loginis only sent to/api/auth/…. Chrome lists it as filtered out on the other requests; Firefox says nothing. - It is HttpOnly.
document.cookiedoes not show it, but it is sent. Check the request'sCookieheader instead. - It was deleted.
Max-Age=0or a pastExpiresremoves the cookie; a logout route often does this.
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