Rumah > pembangunan bahagian belakang > tutorial php > 【PHP】基于 Cookie 的登录和身份认证

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

WBOY
Lepaskan: 2016-07-25 09:11:25
asal
901 orang telah melayarinya
  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. ?>
复制代码


sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan