How to use cookies to display the date of the user's last visit to the website in php, cookie last visit_PHP tutorial

WBOY
Release: 2016-07-13 10:08:59
Original
826 people have browsed it

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.

www.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...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!