I am a bad student == I don’t know how to learn a lot by myself. I want to ask a question from a master. The code in the book is as follows:
<?php
date_default_timezone_set("Etc/GMT-8 ");
if(!isset($_COOKIE["visittime"])){ //If the cookie does not exist
setcookie("visittime",date("y-m-d H:i: s")); //Set a Cookie variable
echo "first time to meet:".date("y-m-d H:i:s")."<br>"; //Output string
}else{ //If Cookie exists
setcookie("visittime",date("y-m-d H:i:s"),time() 60); //Set variables with Cookie expiration time
echo "last time:".$_COOKIE["visittime"]; //Output the time of the last visit to the website----------- --------------
echo "<br>"; //Output carriage return character
}
echo "now : ".date("y-m-d H:i:s"); //Output the current access time *********************
?>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
Rendering For:
First load:
Second Refresh times:
Question: What I want to ask is == created a new cookie file, re-execute this command. Why is the time in setcookie() in the line in the remarks changed to the current time date("y-m-d H:i:s"), and then there is -------- in the remarks? - The line can also output the last time instead of the current time. Then, there is *********** in the remarks but the output is the current time, which is correct== What's going on? What's going on when the line of ------------- arrives? God, please help. T T
寻觅 beyond2017-10-12 23:21:37
PHP Chinese manual says this
Before setting a cookie for the same parameter again, you must delete it first. If the value of the parameter is an empty string or FALSE, and the other parameters are still the same as the last call to setcookie, the specified name will be deleted by the remote client.
Hope this solves your problem