Looking for a simple way to show a welcome message to first time visitors on my website. What\'s the best approach?
Cookie. If the visitor doesn't have the cookie for your site, then display a welcome message. This isn't a foolproof method (it is trivial for a user to delete cookies), however it's the best you can do.
Without an authenticated session (login), you're forced to using a cookie. If the cookie isn't present, set it and simultaneously display the welcome message.
Using a cookie:
if (empty($_COOKIE['first_time'])) {
show_welcome_message();
setcookie("first_time", 1, time()+157680000); /* expire in 5 years */
}
Of course, if the users clears his cookies, he'll see the message again. If he doesn't accept cookies, he'll see the message all the time.