• PHP Script that uses Cookie for login

    Following html and PHP files contains the PHP login script that uses cookie for login:

    >

    Please Specify the Password
    Customer ID
    Password

    CookieBasedLogin.php

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    
    <!--?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-->

    Hi ” . $data[2] . ” ! !

    1
    2
    
    \n";
            echo "<b></b>

    Last Login Time :” .$data[0] . “

    1
    2
    3
    
    <b></b>
    \n";
            echo "<b></b>

    Current Date :” .$storetime. “

    1
    2
    3
    
    <b></b>
    \n";
            echo "<b></b>

    Page View Count :” . $data[l]. “

    1
    2
    3
    
    <b></b>
    \n";
            echo "<b></b>

    You have successfully logged in!

    1
    2
    3
    4
    
    <b></b>";
            echo ("<b>You can access this area without entering a password for the next 24 hours!</b>");
        } else {
            echo "

    INVALID PASSWORD!!!

    1
    2
    3
    
    ";
        }
      ?&gt;

Comments on this post

Leave a Reply

  • Security Code :


    five + = 13