1. Home
  2. Computing & Technology
  3. PHP / MySQL

You Last Visited PHP Script

By Angela Bradley, About.com

4 of 4

New Users

else
{
echo "Welcome to our site!";
//Greets a first time user
}
?>
If $last did not exist, then this code executes. It simply welcomes a first time user to the site. They now have a cookie set in their browser so they will not get this message again.

The top part of the script, that retrieves and sets the cookie, needs to be placed at the very top of a page to work. The rest of this script can run anywhere on your site that you want to welcome a user.

Index: You Last Visited PHP Script

  1. The Full Code
  2. Setting and Retrieving the Cookie
  3. Welcome Back
  4. New Users

4 of 4

Explore PHP / MySQL

More from About.com

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. Step By Steps
  5. Your Last Visit Script - PHP Last Visit Script - Last Time Visited PHP

©2008 About.com, a part of The New York Times Company.

All rights reserved.