Learning center

Login succeeds, then the next request is anonymous: trace the cookie

When a login succeeds but the next request is anonymous, the browser either refused to store the session cookie or did not send it. The login response's Cookies tab and the next request's Cookie header tell you which.

Cause A: the browser refused to store the cookieCause B: the browser stored it and did not send it
Application > CookiesThe cookie is absentThe cookie is present
Login response, Cookies tabThe cookie is listed as blocked, with a reasonThe cookie is listed normally
Next request's Cookie headerMissing the cookieMissing the cookie
Typical attributes involvedSameSite=None without Secure, Secure on a login response that arrived over http:, whatever the page's scheme, a Domain that does not match the host of the login response, which for a cross-origin login is the API's host, not the page'sPath that excludes the next URL, SameSite on a cross-site request, a different host, or a fetch that does not send credentials

The deciding observation is whether the browser stored the cookie after the login response. Application > Storage > Cookies shows it, and the login response's Cookies tab shows whether it was blocked and why. A cookie belongs to the host that set it, so when the login request goes to another host, such as api.example.test from a page on app.example.test, look for it under that host: Domain=api.example.test is valid there even though it does not match the page.

Read the login response#

Select the login request in the Network panel and open its Cookies tab. The tab lists the cookies the response set. A cookie the browser blocked is highlighted; hover its info icon to see the reason. The Network panel also has a filter for requests whose response cookies were blocked. When Chrome settings or flags blocked the cookie, a warning icon on the request links to the Issues panel. Network panel: cookies and blocked cookies · Cookies in DevTools

In a local reproduction with Chromium on http://localhost, a login response set two cookies:

Set-Cookie: sid=abc123; Path=/; HttpOnly; SameSite=None
Set-Cookie: theme=dark; Path=/

Chromium stored theme and blocked sid. The DevTools protocol reported the blocked reason as SameSiteNoneInsecure: a cookie with SameSite=None must also carry Secure. The next request carried Cookie: theme=dark and no session. The server answered as if nobody had logged in. MDN: Set-Cookie attributes · Chrome DevTools Protocol: blocked cookie reasons

Read the next request#

If the cookie is stored, select the first request that came back anonymous and open its Cookies tab, then turn on the option to show filtered-out request cookies. A stored cookie that the browser did not attach appears there with the reason, such as a path mismatch or a SameSite restriction.

Also look at how the page made the request. A fetch to another origin sends cookies only with credentials: "include", and the server must answer with Access-Control-Allow-Credentials: true for the page to read the response. fetch credentials option · MDN: CORS requests with credentials

Worked example: login works on staging, fails behind a new proxy#

This example is fictional. After moving a staging site behind a new TLS-terminating proxy, submitting the login form succeeds, and the dashboard then redirects back to the login page. The form submits as a page navigation, not a fetch.

With Preserve log on, the login produced three rows in the Network panel: POST https://staging.example.test/login answered 307 with a redirect to the http: address, that http: response carried Set-Cookie: session=…; Secure; HttpOnly, and it redirected back to https:. The middle row's Cookies tab showed session highlighted as blocked, because a Secure cookie cannot be set from an insecure connection. The Application panel held no session cookie.

The report said: the proxy redirects POST /login to the http: address before redirecting back to https:. The browser blocks the Secure session cookie on the http: response. The application receives no session on the next request. The fix went to the proxy's redirect rule, not the session code.

What to put in the report#

  • The Set-Cookie header from the login response, with the cookie value replaced by a placeholder.
  • Whether the cookie appears in the Application panel after login.
  • The blocked or filtered-out reason DevTools shows, copied exactly.
  • The next request's URL, method and Cookie header, also with values replaced.
  • The page's address and whether the request is same-site or cross-site.

Questions#

Why does it work in Firefox or Safari but not Chrome, or the reverse?

Browsers differ in defaults, such as how they treat a cookie with no SameSite attribute and how they handle cookies in a third-party context. Record the browser and version, and test the same steps in the others before concluding the server is at fault.

Why does a Secure cookie work on my machine over http: but not on a test server?

Chromium treats localhost and 127.0.0.1 as secure origins. In a local check, a Secure cookie set by http://127.0.0.1 was stored, and the same response from http://staging.test was blocked with the reason SecureOnly. Test cookie attributes on the host name the failure happened on.

The cookie is HttpOnly. Can I still check it?

Yes. HttpOnly hides the cookie from document.cookie but not from DevTools. The Application panel and the Network panel's Cookies tab show it.

Should I paste the cookie into the report?

No. A session cookie lets anyone who holds it act as that user until it expires. Copy the name and attributes, and replace the value with a placeholder.

Return to the method for browser bug reports for the other symptoms in this collection.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading