Use of Cookies

<?php
date_default_timezone_set("Etc/GMT-8");
if(!isset($_COOKIE["visittime"])){ //If Cookie does not exist
     setcookie("visittime",date("ymd H:i:s ")); //Set a cookie variable
    echo "Welcome to the website for the first time!"."<br>"; //Output string
}else{ //If the cookie exists
    setcookie("visittime",date(" ymd H:i:s"),time()+60); //Set a variable with cookie expiration time
    echo "The time you last visited the website was: ".$_COOKIE["visittime"]; //On the output The time of the last visit to the website
    echo "<br>"; //output carriage return
}
    echo "The time of your visit this time is: ".date("ymd H:i:s"); //Output the current visit time
?>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325121368&siteId=291194637