1. About.com
  2. Computing & Technology
  3. PHP / MySQL

Discuss in my forum

You Last Visited PHP Script

By , About.com Guide

1 of 4

The Full Code
 <?php if(isset($_COOKIE['AboutVisit'])) { $last = $_COOKIE['AboutVisit']; } $year = 31536000 + time() ; //this adds one year to the current time, for the cookie expiration setcookie(AboutVisit, time (), $year) ; if (isset ($last)) { $change = time () - $last; if ( $change > 86400) { echo "Welcome back! <br> You last visited on ". date("m/d/y",$last) ; // Tells the user when they last visited if it was over a day ago } else { echo "Thanks for using our site!"; //Gives the user a message if they are visiting again in the same day } } else { echo "Welcome to our site!"; //Greets a first time user } ?> 
More information about how this script works, and what each section does is on the following pages.

©2012 About.com. All rights reserved. 

A part of The New York Times Company.