Friday, 23 August 2013

Best Practice for Cookies

Best Practice for Cookies

There are two approaches I've been thinking about for storing data in
cookies. One way is to use one cookie for all the data and store it as a
JSON string.
The other approach is to use a different cookies for each piece of data.
The negatives I see with the first approach is that it'll take up more
space in the headers because of the extra JSON characters in the cookie.
Also I'll have to parse and stringify the JSON which will take a little
processing time. The positive is that only one cookie is being used. Are
there other positives I am missing?
The negatives I see with the second approach is that there will be more
cookie key value pairs used.
There are about 15-20 cookies that I will be storing. The expires date
will be the same for each cookie.
From what I understand the max number of cookies per domain is around
4000. We are not close to that number yet.
Are there any issue I am overlooking? Which approach would be best?
Thanks!

No comments:

Post a Comment