gigebyte / cookies

Automatically exported from code.google.com/p/cookies
0 stars 0 forks source link

Support multi-value cookies #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What behaviors would you like to see added, changed, or removed?
I would love to be able to set multiple values inside one cookie. Microsoft
has an implementation of this with ASP.NET cookies (see
http://msdn.microsoft.com/en-us/library/78c837bd.aspx) -- specify a cookie
name and get/set multiple name/value pairs. Behind the scenes it's just
concatenating the pairs with a delimiter, which can be done manually. Of
course, the abstraction makes it so much easier to use.

Do you have any objective justification for this?  If your justification is
only subjective, can you convince me?
I think a lot of developers would opt to set fewer cookies if they had the
API support in a cookie plugin like 'cookies'. I for one would like to be
able to separate my cookies by purpose. For example, I'd like one cookie to
store element expand/collapse preferences for a page. I have a dozen or so
elements to deal with (maybe more in the future), and I'd like to
consolidate all those settings.

Additional info:

Original issue reported on code.google.com by chris.p....@gmail.com on 9 Feb 2010 at 2:33

GoogleCodeExporter commented 9 years ago
You are right that with what currently exists you can already do this manually. 
But I also support JSON encoded values so you could set an array or object as a 
cookie...seems it fits the bill?

Thanks,
Jim

Original comment by auldrid...@gmail.com on 10 Nov 2010 at 2:20

GoogleCodeExporter commented 9 years ago
I haven't worked too much with JSON; I get being able to set multiple values 
easily, but how would it work when trying to get just one value by name? Or, 
for that matter, setting one additional value on a cookie that already has 
multiples set.

I don't know that it's not fairly easy; like I said, I'm inexperienced with 
JSON and can't visualize how it'd work.

Original comment by chris.p....@gmail.com on 11 Nov 2010 at 1:14

GoogleCodeExporter commented 9 years ago
Hi Chris,

I have looked at the link you provided and I don't think I am going to head 
down this road. Take a look at the home page of this project in the code 
samples and find the area marked JSON for an example of how to work with the 
JSON client side.

Server side, You'd need to produce your array or simple object of values and 
use a JSON serializer to serialize it to a string to write to your cookie value.

Email me if you have further questions.

Jim

Original comment by auldrid...@gmail.com on 26 Jan 2011 at 8:00