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

php实现用户登录验证有很多方法,最常见的方法是session方法和cookie方法,session方法是服务器登录验证方法,cookie方法是客户端登录验证方法,需要的朋友可以参考下

php cookie用户登录的实现

HTML源码:


php cookie用户登录的实现

Please Specify the Password


php源码:

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!!!
“;
}
}
}
?>

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

作者: dawei

【声明】:永州站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

联系我们

联系我们

0577-28828765

在线咨询: QQ交谈

邮箱: xwei067@foxmail.com

工作时间:周一至周五,9:00-17:30,节假日休息

返回顶部