Heim  >  Artikel  >  Backend-Entwicklung  >  【PHP】基于 Cookie 的登录和身份认证

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

WBOY
WBOYOriginal
2016-07-25 09:11:25849Durchsuche
  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. ?>
复制代码


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn