This article shares an example of using PHP to implement session technology cookies. It is a very simple example and is suitable for reference for getting started with PHP cookies. Friends in need can take a look.
For example, if you want to display the login time, it will prompt you when you log in for the first time, otherwise it will display the time of your last login. Code: <?php //显示上次登录的时间 if(!empty($_COOKIE['lastvisit'])){ echo "您上次登录的时间:".$_COOKIE['lastvisit']; //保存一个星期 setcookie("lastvisit",date("Y-m-d H:i:s"),time()+7*24*3600); }else{ echo "欢迎光临。您是第一次登陆"; setcookie("lastvisit",date("Y-m-d H:i:s"),time()+7*24*3600); } ?> Copy after login |