Lovelock
Lovelock

Reputation: 8085

User Preferences, Store in DB or cookies?

Evening all,

Not sure if this question is really acceptable criteria but ill try anyway.

I need to store user pref. on simple things like; Which order for blog posts to show, comments on and off, etc.

These could be stored via cookies, or possibly in the DB simply with a number variable. No 'personal' data will be stored just basic preferences which can be updated from the users settings page.

What would be the best way? Im more possibly leaning towards the DB way...

Thoughts?

Upvotes: 3

Views: 3022

Answers (1)

Fractaliste
Fractaliste

Reputation: 5957

The best way ? It's depend of your criterias. Yours'll be different of mines.

DB storage is better if you need :

  • Important control of the data (data type, possible values, other security rules...)
  • Permanent storage (cookies are very volatile)
  • Client usage statistical (or other functionality where the admin need access to these preferences)
  • ...

The best advantage of cookies is, in my view, the very fast implementation (no configuration, no table to generate, very easy to use with recent framework). The worst disadvantage is that cookies are only on 1 device.

So what are you criteria of what would be a good solution?

Upvotes: 4

Related Questions