3

In my application I want to prompt a user about a new feature with some kind of a dialog the first time they visit the screen. And on a subsequent visit this dialog is not shown.

The obvious solution is to use a cookie or save this in the database.

But I'm concerned that: - over time all the checks in the code will result in messy code - with the database solution - it can bring performance issues.

And also if the user clears his cookies (for example) I don't want them to see every new feature update for the past two years (one screen can be have multiple new features over time).

Is there a stupid/simple way to handle this? How does twitter and facebook do this when they promote their new features?

My environment is MSSQL, ASP MVC if does matter.

5 Answers5

2

Use both - cookies as a caching technique - first check the cookie. If it doesn't contain the flag - then ask the DB.

Also, you can initialize that cookie at login. One DB call per user session.

Tisho
  • 8,320
  • 6
  • 44
  • 52
1

Personally, I'd use a database flag against the user record.

Like you say, cookies can be destroyed and lead to annoying duplicate reminders.

I don't think you need to worry about "messy code" if you're doing it right.

Widor
  • 13,003
  • 7
  • 42
  • 64
  • but then every time a user visits a page I have to do a check in the database. And that's one of the things I want to avoid. More sql requests = bigger performance hit. – Georgi Varzonovtsev Jun 01 '12 at 17:49
  • @GeorgiVarzonovtsev: Yes, that is correct, but completely necessary for a consistent user experience and account security. What possible alternative is there? Checking only on the login page and then trusting that all URLs which access user content are valid? – wallyk Jun 01 '12 at 18:42
1

Since you have user login, I assume you also have some type of server-side session. You could store user preferences in the database, and cache them in the session upon login, avoiding going to the database for every request. As long as you trust your session for authentication purposes, you certainly can trust it for user preferences.

lanzz
  • 42,060
  • 10
  • 89
  • 98
0

We store it in XML. Then you can use serialization to quickly save/load the settings. We store the XML in SQL (MS SQL have features that support XML)

Gerhard Powell
  • 5,965
  • 5
  • 48
  • 59
0

Well the checks in the code are independant from the place you store the datas, it is a different problem.

As of your question I'ld say to use the database, for speed + ease reasons.

Sebas
  • 21,192
  • 9
  • 55
  • 109