Display a welcome back message to your wordpress visitors
November 18, 2008 · Print This Article
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.
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.
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!”;
}
?>





















Comments
Got something to say?
You must be logged in to post a comment.