php cookie用户登录的详解及实例代码

前端之家收集整理的这篇文章主要介绍了php cookie用户登录的详解及实例代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

PHP cookie用户登录的实现

HTML源码:

<a href="https://www.jb51.cc/tag/PHP/" target="_blank" class="keywords">PHP</a> cookie<a href="https://www.jb51.cc/tag/yonghu/" target="_blank" class="keywords">用户</a><a href="https://www.jb51.cc/tag/denglu/" target="_blank" class="keywords">登录</a>的实现
PHP">
Please Specify the Password

PHP源码:

PHP;"> PHP $now = getdate(); $storetime= $now["weekday"] . " " . $now["month"] ." " . $now["year"] ; $storetime.=" Time : ";

if ($now["hours"] < 10) {
$storetime.= "0" . $now["hours"];
} else {
$storetime.= $now["hours"];
}

$storetime.= ":";
if ($now["minutes"]<10) {
$storetime.= "0" . $now["minutes"];
} else {
$storetime.= $now["minutes"];
}

$storetime.= ": ";
if ($now["seconds"] <10) {
$storetime.= "0" . $now["seconds"];
} else {
$storetime.= $now["seconds"];
}
if (isset($data)) {
$counter=++$data[l];
setcookie("data[0]",$storetime,time() + (606024));
setcookie("data[l]",$counter,time() + (606024)); setcookie("data[2]",$username,time() + (606024));
echo "

Hi " . $data[2] . " ! !

\n";
echo "
Last Login Time :" .$data[0] . "

\n";
echo "
Current Date :" .$storetime. "

\n";
echo "
Page View Count :" . $data[l]. "

\n";
echo "
You have successfully logged in!
";
echo ("You can access this area without entering a password for the next 24 hours!");
} else {
if (isset($username) && isset($password)) {
if ($password=="superpass") {
$counter=0;
setcookie("data[0]",time() + (606024));
setcookie("data[l]",time() + (606024));
setcookie("data[2]",time() + (606024));
$url="Location: cookieimp.PHP";
header($url);
}else{
echo "
INVALID PASSWORD!!!
";
}
}
}
?>

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持

原文链接:https://www.f2er.com/php/18164.html

猜你在找的PHP相关文章