cookies icon indicating copy to clipboard operation
cookies copied to clipboard

Have a way to get all cookie names

Open joeyespo opened this issue 11 years ago • 10 comments
trafficstars

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!

joeyespo avatar Aug 04 '14 19:08 joeyespo

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 avatar Aug 04 '14 21:08 jonathanong

@jonathanong Sure. Working with cookies in Node has just been a very fragmented experience. This would help smooth it out a bit.

joeyespo avatar Aug 04 '14 21:08 joeyespo

is there a workaround for this issue?

tonyxiao avatar Sep 12 '16 02:09 tonyxiao

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.

dougwilson avatar Sep 12 '16 02:09 dougwilson

Has there been any progress on implementing this feature?

House3272 avatar Oct 21 '16 19:10 House3272

No PR has been submitted yet, so I assume no.

dougwilson avatar Oct 21 '16 19:10 dougwilson

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.

shri3k avatar Jun 16 '17 23:06 shri3k

@dougwilson would you be interested in a PR with the above changes (with tests/docs update too of course)?

shri3k avatar Jun 24 '17 02:06 shri3k

@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.

creeperyang avatar Aug 08 '17 10:08 creeperyang

i also want to get all cookies; it would be good if support;

Rimin avatar Oct 09 '21 11:10 Rimin