Cookie Settings Storage Method
Posted
by
Paul
on Programmers
See other posts from Programmers
or by Paul
Published on 2012-11-20T18:29:18Z
Indexed on
2012/11/20
23:20 UTC
Read the original article
Hit count: 156
architecture
|cookies
I've got an web app that needs to store some non-sensitive preferences for the user. Right now I'm storing their language preference and what mode they want a window opened in by default in two cookies:
- "lang" can be "en" or "de"
- "mode" can be "design" or "view"
I might add a few more in the future. I'm not sure how many, but probably never more than a dozen.
Language is parsed on every request, whereas the mode cookie is only used occasionally. I saw a recommendation that made sense I shouldn't try to do what I was originally planning to do and strongly type a user settings class deserialized on each request because of the overhead involved.
I see three options here and I'm not sure which is the best overall.
- Keep things as they are, add a new cookie for each new setting
- Combine the cookies into a single settings cookie and add future values to it
- Change the mode cookie to settings (leaving language alone), add new user settings values to the settings cookie
All would work obviously. I'm leaning toward option three, but I'm not sure if there's a best practice for this?
© Programmers or respective owner