x
 
Create New Page
 View Previous Changes    ( Last updated by Vik )

Recognizing Repeat Visitors By Name

If a reader of your blog fills in his or her contact info and checks the ‘Remember my personal information’ checkbox, EE stores that info in a cookie on the reader’s computer. Cookies are automatically retrieved by the client’s browser and sent back to the server. You just need some PHP code that knows where to find the data. I looked up how to do it in ‘PHP5 and MySQL Bible’ from Wiley.

<!-- Greet user by name if name info is available -->
<?php
if (IsSet($_COOKIE['exp_my_name'])) {
$UserName
= $_COOKIE['exp_my_name'];
echo
'Welcome back, ';
echo
$UserName;
echo
'.';
}
?>

Turn on PHP in the template in which you use this code.

Category:Tricks

Categories: