Home >Backend Development >PHP Tutorial > cookie,该如何处理

cookie,该如何处理

WBOY
WBOYOriginal
2016-06-13 13:41:56857browse

cookie

header('Content-Type:text/html;charset=utf-8');
if(!empty($_COOKIE['lastVist'])) {
echo "你上次登陆的时间是".$_COOKIE['lastVisit'];
setcookie("lastVisit",date("y-m-d H:i:s"),time()+24*3600*30);

}else {
echo "你是第一次登录";
setcookie("lastVisit",date("y-m-d H:i:s"),time()+24*3600*30);
}


?>

cookie初始化失败,
老是第一次登陆,
无法显示上次登陆时间,是怎么回事?

------解决方案--------------------
if(!empty($_COOKIE['lastVisit'])) {

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