Can't set multiple cookies with res.cookie
See original GitHub issueProblem with res.cookie
I am trying to set multiple cookies with res.cookie
.
(Only the last one saved)
My code:
const cookieParser = require('@tinyhttp/cookie-parser').cookieParser;
const TinyApp = require('@tinyhttp/app').App;
const app = new TinyApp();
const parse = cookieParser(CookieSecret);
const cookieTime = 1000 * 60 * 60 * 24 * 3;
app.get("/SetInfo", async (req, res) => {
if(req.query.cookies){
await new Promise(next => parse(req, res, next));
res.cookie("name", 1, { httpOnly: true, signed: true, maxAge: cookieTime });
res.cookie("pass", 1, { httpOnly: true, signed: true, maxAge: cookieTime });
console.log(req.signedCookies);
// {pass: 1}
}
res.send('ok');
res.end();
})
app.listen(8080);
I tried @tinyhttp/cookie-parser
and cookie-parser
, but the same results.
Versions
node
: 12.19.0@tinyhttp/app
: 1.1.5@tinyhttp/cookie-parser
: 1.1.6
Does someone know what may be the problem?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How set multiple cookies with res.cookie(key , value) on ...
You simply call cookie more than once without calling send in between them. Call send only after you've done all the cookies, ...
Read more >Can't set multiple cookies with res.cookie · Issue #215 · tinyhttp ...
Problem with res.cookie I am trying to set multiple cookies with res.cookie. (Only the last one saved) My code: const cookieParser ...
Read more >SameSite cookies - HTTP - MDN Web Docs
Cookies will be sent in all contexts, i.e. in responses to both first-party and cross-site requests. If SameSite=None is set, the cookie ......
Read more >ExpressJS - Cookies - Tutorialspoint
ExpressJS - Cookies, Cookies are simple, small files/data that are sent to client with a server request and stored on the client side....
Read more >Using cookies - Postman Learning Center
You can't override cookie headers directly in the Headers tab. Edit the cookie in the cookie manager, or delete the cookie and set...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok i think this is fixed, at least tests for multiple
res.cookie
calls pass.to install:
lmk if the issue still occurs or you need extra help about it
Greate, thanks for the help. BTW I adore this framework. The speed is Amazing! (~ ̄▽ ̄)~