question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cookies headers are present but Cookies are not stored in browser

See original GitHub issue

I’m making cross-domain request between two subdomains: sub1.local and sub2.local. Both are on local, as you see.

So I send POST from sub1.local to sub2.local. I recevie Cookie header: Set-Cookie: name=value; expires=Sun, 20-May-2018 21:38:08 GMT; Max-Age=3600; path=/; domain=.local. But there is no Cookie in browser storage.

All response headers:

HTTP/1.1 200 OK
Date: Sun, 20 May 2018 20:43:05 GMT
Server: Apache
Set-Cookie: name=value; expires=Sun, 20-May-2018 21:43:05 GMT; Max-Age=3600; path=/; domain=.local
Cache-Control: no-cache, private
Access-Control-Allow-Origin: http://sub1.local:8080
Vary: Origin
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 59
Content-Length: 2
Keep-Alive: timeout=10, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

What can be wrong?

I’ve tried add withCredentials: true after reading this question - didn’t helped.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16

github_iconTop GitHub Comments

9reactions
Skinner927commented, Mar 28, 2019

For any poor SOB who lands on this page as I did, 127.0.0.1 != localhost. If you are serving your site from localhost(port whatever) and making CORS requests to 127.0.0.1 (port whatever) cookies will not stick! Ensure to use either only localhost or only 127.0.0.1, but do not mix and match.

7reactions
Tarasovychcommented, May 25, 2018

I’ve found an answer on stack about the problem that Chrome won’t set Cookie if there is port in domain url. Can I remove port from domain url? I’m using vue-cli.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cookies headers are present but Cookies are not stored in ...
You seem to be using CORS. To set a cookie with CORS you'll need to set the withCredentials flag when making the request....
Read more >
7 Keys to the Mystery of a Missing Cookie - Medium
Check out the OPTIONS response header ACCESS-CONTROL-ALLOW-CREDENTIAL whether it is set to true . If the server doesn't allow credentials being ...
Read more >
Set-Cookie in response header not stored in the browser, not ...
There could be multiple reasons for set-cookie response headers not being able to set cookies in the browser. We have listed them down...
Read more >
cookies header are present but cookies are not stored ... - Reddit
Please help me to figure out why the browser (Chrome and any others) does not set cookies, while Set-Cookie header is present in...
Read more >
Cookies headers are present but Cookies are not stored in ...
Related Query · Cookies headers are present but Cookies are not stored in browser · Custom cookie sent to browser but not stored...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found