cookies
cookies copied to clipboard
Have a way to get all cookie names
This library is wonderful for getting and setting individual cookies. I have a case where I need to get all cookies though.
It'd be nice to just re-use the get() function without specifying a key:
var cookies = new Cookies(req, res, keys);
var allCookies = cookies.get();
Thanks for your hard work!
This isn't really the purpose of this module. but I think we should be able to do .names() or something to get all the cookie names.
@jonathanong Sure. Working with cookies in Node has just been a very fragmented experience. This would help smooth it out a bit.
is there a workaround for this issue?
No workaround unless you parse the header yourself, at which point you're probably just not using this module. If someone makes a PR, we can take a look.
Has there been any progress on implementing this feature?
No PR has been submitted yet, so I assume no.
Correct me if I'm wrong but wouldn't the PR just be adding
if (!name) return header
in this line? or I might have misunderstood on what is being requested.
@dougwilson would you be interested in a PR with the above changes (with tests/docs update too of course)?
@shri3k No, the header here is just raw cookie string.
The express cookie middleware will parse the entire cookie string and generate the all cookie object.
Can we do this too? Such as when call ctx.cookie.get(name) first time, we parse the entire cookie string to the object and cache it.
i also want to get all cookies; it would be good if support;