-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Update res.cookie for setting multiple cookies in a single response #1063
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I have updated the doc to show how multiple key values for a cookie can be set.
|
Hey @hematy61, I am interested in what this adds which is not covered or clear with the existing docs? Was it unclear from the existing docs how to do this? |
|
Hey @wesleytodd. thanks for asking. I didn't find anything mentioning how to add more than one key value to a cookie. is there any? if there is, shouldn't it be mentioned here as well? |
Not sure what you mean by this. A cookie can have only one value. In your example you are just adding two separate cookies, which is basically the same code as the example above: I was just wondering if that code snippet is not enough to illustrate the point. If not, I could see maybe using the same code block and adding to the paragraph above it a point about "this example sets two cookies in one response" or something to that effect. Make sense? |
|
I see what you mean. In the beginning, I was confused about how I can set 2 or more key values in one request. technically, res.cookie( 'key1', 'value1')
res.cookie( 'key2', 'value2')
res.send()is the same as chaining them together like: res.cookie( 'key1', 'value1')
.cookie( 'key2', 'value2')
.send()but for someone who doesn't know chaining is working here, it's gonna be confusing (as it was for me). I had to search to see how I can add multiple key values in one response. I hope my point makes sense now. |
|
That makes way more sense to me now. I think a great addition would be to show that you can do either of those with a single line of "You can set multiple cookies in a single response by calling |
|
Right on. that's it. And I have modified it with what you have suggested. |
|
Looks fine to me now. Just needs formatting cleanup, use two space indentation, single quotes, and no semicolons (sorry for the nitpicks, but gotta keep things consistent with the formatting guidelines moving forward!). @crandmck do you have opinions on this addition? |
|
No worries. it should be good now. |
|
shouldn't we close it? |
|
LGTM... Thanks for the contribution! |
expressjs#1063 Co-Authored-By: Mo <[email protected]>
* Include 4.18 API doc updates in 5.x 5c98ee4 Co-authored-by: Douglas Christopher Wilson <[email protected]> * Copy acceptsLanguages documentation improvements to 5.x #1402 Co-authored-by: Jon Ege Ronnenberg <[email protected]> * Add warning boxes to {app,res}.render 5e918ea Co-authored-by: Douglas Christopher Wilson <[email protected]> * Copy warning around securing locals to 5.x fcaca7f Co-authored-by: Douglas Christopher Wilson <[email protected]> * Copy res.cookie `partitioned` option docs #1456 Co-authored-by: Rich Hodgkins <[email protected]> * Update req.body to point to built-in middleware a5ca5b0 Co-Authored-By: Douglas Wilson <[email protected]> * Copy setting multiple cookies example to 5.x #1063 Co-Authored-By: Mo <[email protected]> --------- Co-authored-by: krzysdz <[email protected]> Co-authored-by: Douglas Christopher Wilson <[email protected]> Co-authored-by: Jon Ege Ronnenberg <[email protected]> Co-authored-by: Rich Hodgkins <[email protected]> Co-authored-by: Mo <[email protected]>
I have updated the doc to show how multiple key values for a cookie can be set.