Link to home
Start Free TrialLog in
Avatar of nzinsli
nzinsliFlag for United States of America

asked on

Cookies: Key/Value pairs vs separate cookies

Can anyone tell me what the pros/cons are of using a single cookie with multiple key/value pairs vs using multiple cookies with a single value? I'm wondering if there are performance benefits or issues, or other programming pros/cons for one or the other.
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

I don't think there's a performance difference.  The only issue I can think of is keeping track of the different names.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nzinsli

ASKER

Is the 4k limit per cookie, or as a total for all cookies for the domain?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nzinsli

ASKER

Thanks.

Is there any real performance concerns in .Net with the code needed to retrieve a cookie value vs parsing the key/value pairs?
Retrieving a cookie requires a round trip to the client.  That's subject to the vagarities of the network.  Parsing key/values will be done as fast as the local machine can make it happen.
> Retrieving a cookie requires a round trip to the client.  That's subject to the vagarities of the network.  Parsing key/values will be done as fast as the local machine can make it happen.
      

@paulmacd

It does not work that way. The cookies are posted to the server along the request by the client and are parsed on the server.

"When a browser makes a request to the server, it sends the cookies for that server along with the request."


http://msdn.microsoft.com/en-us/library/aa289495%28v=vs.71%29.aspx#vbtchaspnetcookies101anchor8
Hey, I learned something!

In any case, having fewer cookies means less overhead.
Avatar of nzinsli

ASKER

Thanks!