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

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.
Explore PHP / MySQL
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  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

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

All rights reserved.