欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php利用cookie實(shí)現(xiàn)自動(dòng)登錄的方法

 更新時(shí)間:2014年12月10日 09:50:51   投稿:shichen2014  
這篇文章主要介紹了php利用cookie實(shí)現(xiàn)自動(dòng)登錄的方法,涉及針對(duì)cookie的讀取判斷及登陸操作,是非常實(shí)用的技巧,需要的朋友可以參考下

本文實(shí)例講述了php利用cookie實(shí)現(xiàn)自動(dòng)登錄的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

html前端頁(yè)面代碼如下:

復(fù)制代碼 代碼如下:
<html>
  <head>
  <title>enter password</title>
  </head>
  <body>
  <form name="forml" method="post" action="cookiebasedpasswordlogin.php">
    <table>
      <tr>
       <td colspan="2" >
         <div align="center"><b>please specify the password</b></div>
       </td>
     </tr>
   <tr>>
     <td>
       <div align="right">customer id</div>
     </td>
     <td>
       <input type="text" name="username">
     </td>
   </tr>
   <tr>
     <td>
       <div align="right">password</div>
     </td>
     <td>
       <input type="password" name="password">
     </td>
   </tr>
   <tr>
     <td colspan="2">
       <center>
         <input type="submit" name="submit" value="login">
       </center>
     </td>
    </tr>
   </table>
  </form>
  </body>
</html>

后端PHP代碼如下:
復(fù)制代碼 代碼如下:
<?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() + (60*60*24));
        setcookie("data[l]", $counter,time() + (60*60*24)); setcookie("data[2]",$username,time() + (60*60*24));
        echo "<b><center>hi " . $data[2] . " ! !</center></b><br>n";
        echo "<b><center>last login time :" .$data[0] . "</center></b><br>n";
        echo "<b><center>current date :" .$storetime. "</center></b><br>n";
        echo "<b><center>page view count :" . $data[l]. "</center></b><br>n";
        echo "<b><center>you have successfully logged in!</center></b>";
        echo ("<b><contor>you can access this area without entering a password for the next 24 hours!</center></b>");
   } else {
    if (isset($username) && isset($password)) {
     if ($password=="superpass") {
          $counter=0;
          setcookie("data[0]",$storetime,time() + (60*60*24));
          setcookie("data[l]",$counter,time() + (60*60*24));
          setcookie("data[2]",$username,time() + (60*60*24));
          $url="location: cookieimp.php";
          header($url);
     }else{
          echo "<hl><center>invalid password!!!</center></hl>";
     }
    }
}
?>

希望本文所述對(duì)大家的PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • 探討PHP JSON中文亂碼的解決方法詳解

    探討PHP JSON中文亂碼的解決方法詳解

    本篇文章是對(duì)PHP中JSON中文亂碼的解決方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06
  • PHP高精確度運(yùn)算BC函數(shù)庫(kù)實(shí)例詳解

    PHP高精確度運(yùn)算BC函數(shù)庫(kù)實(shí)例詳解

    這篇文章主要介紹了PHP高精確度運(yùn)算BC函數(shù)庫(kù),結(jié)合實(shí)例形式分析了BC函數(shù)庫(kù)中bccomp、bcadd、bcsub、bcmod、bcdiv、bcmul等函數(shù)的功能以及高精度數(shù)學(xué)運(yùn)算使用方法,需要的朋友可以參考下
    2017-08-08
  • 淺析HTTP消息頭網(wǎng)頁(yè)緩存控制以及header常用指令介紹

    淺析HTTP消息頭網(wǎng)頁(yè)緩存控制以及header常用指令介紹

    本篇文章是對(duì)HTTP消息頭網(wǎng)頁(yè)緩存控制以及header常用指令進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06
  • PHP時(shí)間處理類(lèi)操作示例

    PHP時(shí)間處理類(lèi)操作示例

    這篇文章主要介紹了PHP時(shí)間處理類(lèi),結(jié)合實(shí)例形式分析了DateTime、DateTimeZone、DateInterval及DatePeriod等常用日期時(shí)間處理類(lèi)簡(jiǎn)單操作技巧,需要的朋友可以參考下
    2018-09-09
  • PHP 抽象方法與抽象類(lèi)abstract關(guān)鍵字介紹及應(yīng)用

    PHP 抽象方法與抽象類(lèi)abstract關(guān)鍵字介紹及應(yīng)用

    抽象方法指沒(méi)有方法體的方法,只要一個(gè)類(lèi)里面有一個(gè)方法是抽象方法,那么這個(gè)類(lèi)就要定義為抽象類(lèi),不了解的朋友可以看看
    2014-10-10
  • PHP 雜談《重構(gòu)-改善既有代碼的設(shè)計(jì)》之三 重新組織數(shù)據(jù)

    PHP 雜談《重構(gòu)-改善既有代碼的設(shè)計(jì)》之三 重新組織數(shù)據(jù)

    承接上文的PHP 雜談《重構(gòu)-改善既有代碼的設(shè)計(jì)》之 重新組織你的函數(shù)繼續(xù)重構(gòu)方面的內(nèi)容
    2012-04-04
  • 小文件php+SQLite存儲(chǔ)方案

    小文件php+SQLite存儲(chǔ)方案

    在互聯(lián)網(wǎng)快速發(fā)展的背景下,網(wǎng)絡(luò)上的數(shù)據(jù)內(nèi)容呈幾何級(jí)的增長(zhǎng),而其中增長(zhǎng)最快并且最容易給信息基礎(chǔ)架構(gòu)帶來(lái)挑戰(zhàn)的就是數(shù)目龐大的小文件(如圖片、電子圖書(shū)、郵件等)。
    2010-09-09
  • 深入解析php中的foreach函數(shù)

    深入解析php中的foreach函數(shù)

    以下是對(duì)php中的foreach函數(shù)進(jìn)行了詳細(xì)的分析介紹,需要的朋友可以過(guò)來(lái)參考下
    2013-08-08
  • Apache中php.ini的設(shè)置方法

    Apache中php.ini的設(shè)置方法

    無(wú)論是IIS 還是 Apache, 在啟動(dòng)PHP的時(shí)候,默認(rèn)都從系統(tǒng)變量"C:\Windows"這個(gè)目錄中尋找。 如果要在系統(tǒng)中同時(shí)使用IIS和Apache來(lái)運(yùn)行PHP,而且PHP的版本又不一樣,那么需要為Apache指定自己的PHP環(huán)境。
    2013-02-02
  • PHP7內(nèi)核CGI與FastCGI詳解

    PHP7內(nèi)核CGI與FastCGI詳解

    在本篇文章里小編給大家整理了關(guān)于PHP7內(nèi)核CGI與FastCGI的相關(guān)知識(shí)點(diǎn)內(nèi)容,需要的朋友們學(xué)習(xí)下。
    2019-04-04

最新評(píng)論