【PHP】基于 Cookie 的登录和身份认证

WBOY
发布: 2016-07-25 09:11:25
原创
880 人浏览过
  1. Enter Password
  2. >
  3. Please Specify the Password
  4. Customer ID
  5. Password
复制代码
  1. $now = getdate();
  2. $storetime= $now["weekday"] . " " . $now["month"] ." " . $now["year"] ;
  3. $storetime.=" Time : ";
  4. if ($now["hours"] $storetime.= "0" . $now["hours"];
  5. } else {
  6. $storetime.= $now["hours"];
  7. }
  8. $storetime.= ":";
  9. if ($now["minutes"] $storetime.= "0" . $now["minutes"];
  10. } else {
  11. $storetime.= $now["minutes"];
  12. }
  13. $storetime.= ": ";
  14. if ($now["seconds"] $storetime.= "0" . $now["seconds"];
  15. } else {
  16. $storetime.= $now["seconds"];
  17. }
  18. if (isset($data)) {
  19. $counter=++$data[l];
  20. setcookie("data[0]",$storetime,time() + (60*60*24));
  21. setcookie("data[l]", $counter,time() + (60*60*24)); setcookie("data[2]",$username,time() + (60*60*24));
  22. echo "
    Hi " . $data[2] . " ! !

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

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

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

    \n";
  26. echo "
    You have successfully logged in!
    ";
  27. echo ("You can access this area without entering a password for the next 24 hours!");
  28. } else {
  29. if (isset($username) && isset($password)) {
  30. if ($password=="superpass") {
  31. $counter=0;
  32. setcookie("data[0]",$storetime,time() + (60*60*24));
  33. setcookie("data[l]",$counter,time() + (60*60*24));
  34. setcookie("data[2]",$username,time() + (60*60*24));
  35. $url="Location: cookieimp.php";
  36. header($url);
  37. }else{
  38. echo "
    INVALID PASSWORD!!!
    ";
  39. }
  40. }
  41. }
  42. ?>
复制代码


来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板