0

I was working on a web app and thought it would be awesome to give the user a tooltip or side note on a new feature that has been added.

This would be similar to the way Google or Facebook displays their tips about updates.

I had an idea of setting a cookie (or session variable) to say that the tip has been viewed and not display it again, but this would be running an unnecessary if statement on every page load.

Here is what I have so far:

if ($_COOKIE['displayTip'] != 'no') {
    echo "tip";
}

Are there better ways of doing this, or is one if every page load worth it?

ToXic73
  • 332
  • 6
  • 15
  • 1
    Keep it simple. What if user forgets the tip, needs to look again, etc... Simple html, no javascript, no php, it just works. ref: `http://stackoverflow.com/questions/11022843/add-hover-text-without-javascript-like-we-hover-on-a-users-reputation` The big problem of course is mobile (tablets / phones...) as there is no hover... – zipzit Jun 29 '15 at 02:12

1 Answers1

3

A single if - especially if it is not checking a database - is no problem. Don't worry about it, you can waste more CPU time with other things. If it adds functionality its fine.

One thing you could do is to have the logic on in the Browser (JavaScript) only. This has the advantage you do not have to generate two different pages. This might be beneficial for caching. In JS you can also access cookies to make that seen flag persistent.

eckes
  • 10,103
  • 1
  • 59
  • 71