What about displaying a customized welcome message to your readers? Do you know that you can use the cookie sended by the comment form to get the name of the reader? Let’s use it to create a very cool welcome message.
What about displaying a customized welcome message to your readers? Do you know that you can use the cookie sended by the comment form to get the name of the reader? Let’s use it to create a very cool welcome message.
Nothing hard here: Simply paste the following code wherever you want on your template.
<?php
if(isset($_COOKIE['comment_author_'.COOKIEHASH])) {
$lastCommenter = $_COOKIE['comment_author_'.COOKIEHASH];
echo "Welcome Back ". $lastCommenter ."!";
} else {
echo "Welcome, Guest!";
}
?>
First, we checked if the visitor have a cookie called comment_author_xxx. If he have, we can get his name and display it on the welcome message. If the cookie doesn't exists, we simply welcome the visitor as a guest.
Credits goes to ifohdesigns for this awesome script!
20 Responses
hi
thanks for your great site & great job
i would love to know ” how crate a Archive page like you did”
i will waitng for your recipe .
@kamran: Why not! Get the rss feed so you’ll not miss it =)
i am in for 2 month
i am fan of your site
:p
That’s good to hear =)
Thanks jbj and ifoh for this cool tip!
You’re welcome! Glad it helped.
Great site, I’ve been following it for over a month now on RSS and find these small little tips to be extremely useful.
This latest welcome back message is cool, how about one for just new readers?
@Dave: That’s a great idea for a future recipe, thank you =)
The best site ever. Congrats. Keep doing this wonderful work. M.
@Mike: hehe, this is flattering althought I’m don’t agree with you
Thanks!
Thanks for the useful tutorial! I think a welcome back message can be handy if utilized properly.
Thanks for the useful tip!
Trackbacks: