Pages

Sunday, November 10, 2013

Program 9

9.

Write a PHP program to store current date-time in a COOKIE and display the ‘Last visited on’ date-time on the web page upon reopening of the same page.


<?php

date_default_timeZone_set('Asia/Calcutta');
$inTwoMonths=60*24*60+time();
setcookie('lastVisit',date("G:i-m/d/y"),$inTwoMonths);
if(isset($_COOKIE['lastVisit']))
{
$visit=$_COOKIE['lastVisit'];
echo "Your last visit was -".$visit;
}
else
echo "you ve got some stale cookies!";

?>

No comments:

Post a Comment