PHP PROGRAM
To store current date and time in a cookie and display last visited on date and time |PHP Program|
<html>
<h2>Last visited time on web page</h2>
<br>
<?php
$intm=60*60*24*60+time();
setcookie('lastVisit',date("G:i-m/d/y"),$intm);
if(isset($_COOKIE['lastVisit']))
{
$visit=$_COOKIE['lastVisit'];
echo "Your last visit was ".$visit;
}
else
echo "you have got same state cookies!";
?>
</body>
</html>
OUTPUT
<h2>Last visited time on web page</h2>
<br>
<?php
$intm=60*60*24*60+time();
setcookie('lastVisit',date("G:i-m/d/y"),$intm);
if(isset($_COOKIE['lastVisit']))
{
$visit=$_COOKIE['lastVisit'];
echo "Your last visit was ".$visit;
}
else
echo "you have got same state cookies!";
?>
</body>
</html>
OUTPUT
Post a Comment
0 Comments