Sometimes you want to detect new users on your site versus returning visitors and display different sorts of information to them. An easy way to do this is to set a cookie.
If you’re doing this via a theme, add this line to your functions.php file:
You can read more about the setcookie function at PHP.net. This will set a new cookie named “sitename_newvisitor” with a value of 1 which is set to expire in two weeks.
To display different information to a returning user vs a new user, you could do something like this:
Also, be aware, if your site has heavy caching, reading and setting the cookies may not work.