php uses cookies to display the date of the user’s last visit to the website, cookie last visit
The example in this article describes how PHP uses cookies to display the date of the user's last visit to the website. Share it with everyone for your reference. The specific implementation method is as follows:
Copy code The code is as follows:
if(!empty($_COOKIE['lastvisit'])){//First determine whether there is a cookie
echo "Your last visit time was:".$_COOKIE['lastvisit'];
setCookie("lastvisit",date("Y-m-d H:i:s"),time()+3600*24*360);
}else{
echo "This is your first time logging in, welcome!";
setCookie("lastvisit",date("Y-m-d H:i:s"),time()+3600*24*360);
}
?>
Every time this is refreshed, the time will be updated. In actual applications, it is more likely to display the time when the user last logged in, and will be added later.
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/947917.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/947917.htmlTechArticlephp uses cookies to display the date of the user’s last visit to the website. The cookie was last visited. The example of this article describes the use of cookies by php A method that displays the date the user last visited the website. Share it with everyone...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn