On a blog I am working on, I use a cookie to save a user preference on which side of the layout that the sidebar should show, so I have a cookie something like this…
name: sidebar_switcher
value: right or left
No wI just built a Modal/screen overlay DIV that shows on users first visit, I made it set a DIV once this Modal window is hidden/closed so that I don’t nag the user on every visit with it. SO I now have another cookie being saved like this…
name: subscribe
value: yes or no
So my question, since each Cookie is a new HTTP request as far as I know, should I instead be storing these values into 1 cookie? If that is the case, then should I do it as a JSON string?
Thanks for advice
You could store it as one cookie, or you could use
localStorage()with a fallback on cookies.That way, your users with modern browsers don’t need to parse any cookies around.