Best Practice for Cookies -


there 2 approaches i've been thinking storing data in cookies. 1 way use 1 cookie data , store json string.

the other approach use different cookies each piece of data.

the negatives see first approach it'll take more space in headers because of json characters in cookie. i'll have parse , stringify json take little processing time. positive 1 cookie being used. there other positives missing?

the negatives see second approach there more cookie key value pairs used.

there 15-20 cookies storing. expires date same each cookie.

from understand max number of cookies per domain around 4000. not close number yet.

are there issue overlooking? approach best?

edit - these cookies managed javascript.

if hand out data storage users (which cookies do), should encrypt data, or @ very least sign it.

this needed protect data tampering.

at point, size considerations way off (due padding), , performance overhead of parsing json (encryption cause greater overhead).


conclusion: store data json, (encrypt it), sign it, encode base64, , store in single cookie. keep in mind there is maximum size cookies (and it's 4k).

reference: among numerous other frameworks , applications, what rails does.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -