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.

Set Cookie as post response?

See original GitHub issue

It could very well be that I am missing something basic here, but why cannot I set a cookie as a response to a cookie? Here is my over simplified code that does not set a cookie for some reason: app.post('*', (req,res) => { req.session.userName = "John Doe"; res.end() }) My use case would be when the user logs in, the body of the post is parsed, and the name she logged in with will be saved to the session cookie.

Setting cookies as responses to get requests is not a problem.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
rscharfercommented, Jan 29, 2018

Hi there. I figured it out! I was making the POST with fetch() on the client side, and I needed to add credentials: 'same-origin' to the fetch() configuration object. : ) I still do not know why the browser will not render text or html when I respond to a POST request with that, but that’s a topic for a different forum. (You can see the body of the response in the browser dev tools, but for whatever reason, the browser doesn’t render it.) Anyway, thanks for the help!!

0reactions
dougwilsoncommented, Jan 29, 2018

Hi! Thanks so much for getting that for me! I was thinking of looking into this today, but I think I instead need to focus on https://github.com/expressjs/generator/pull/190#issuecomment-361248460 as it sounds more urgent I think. Once that is done, I’ll come back to this next, but it is unlikely to be today, very sorry 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set-Cookie - HTTP - MDN Web Docs
The Set-Cookie HTTP response header is used to send a cookie from the server to the user agent, so that the user agent...
Read more >
Set-Cookie in Response Header not being created in browser
1 Answer 1 · 1. You need to add the following headers on the server · 2. Be precise about how you set...
Read more >
How to send cookies to the server? - ReqBin
Servers store cookies in the client browser by returning "Set-Cookie: name=value" HTTP headers in the response. In this Send Cookies Example ...
Read more >
Using cookies - Postman Learning Center
To manage cookies in Postman, open a request, then select Cookies (under Send). ... The Manage Cookies window displays a list of domains...
Read more >
About http POST Response.headers set-cookie #362 - GitHub
About http POST Response.headers set-cookie #362. Open. jet10000 opened this issue on Jan 9, 2020 · 5 comments.
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