[PHP] Cool Cookie Login/Logout/Control Panel

Results 1 to 9 of 9
  1. #1
    Proficient Member Virtue~ is offline
    MemberRank
    Jul 2008 Join Date
    181Posts

    [PHP] Cool Cookie Login/Logout/Control Panel

    Just was messing arround.
    And got this.

    Example: http://elitetactics.sytes.net/login.php

    Login.php
    PHP Code:
    <form action='cp.php?' name='login' action='get'>
        
    User <input type='text' name='user'><br>
        
    Pass <input type='password' name='pass'><br>
        
    Email <input type='text' name='mail'><br>
        <
    input type='submit' value='Login'>
    </
    form
    Cp.php
    PHP Code:
    <?php 
    $user2
    =$_GET['user'];
    $pass2=$_GET['pass'];
    $email=$_GET['mail'];
    setcookie("user"$user2time()+3600);
    setcookie("pass"$pass2time()+3600);
    setcookie("mail"$emailtime()+3600);
    ?>

    <html>
    <body>

    <?php
    if (isset($_COOKIE["user"]))
      echo 
    "Welcome " $_COOKIE["user"] . "!<br />";
    else
      echo 
    "Welcome Guest!<br />";
    ?>
    <?php
    if (isset($_COOKIE["pass"]))
      echo 
    "Your Password is " $_COOKIE["pass"] . "!<br />";
    else
      echo 
    "No Password<br />";
    ?>
    <?php
    if (isset($_COOKIE["mail"]))
      echo 
    "Your Email is " $_COOKIE["mail"] . "!<br />";
    else
      echo 
    "No Email<br />";
    ?>

    <br><b><a href=logout.php>Logout</a>
    <br><b><a href=login.php>Sing In</a></b>
    <br>Refresh For your information to appear.
    </body>
    </html>
    logout.php
    PHP Code:
    <?php 
    setcookie
    ("user"$usertime()-3600);
    ?>
    <?php 
    setcookie
    ("pass"$pass2time()-3600);
    ?>
    <?php 
    setcookie
    ("mail"$emailtime()-3600);
    ?>
    You are loggout out.<br><b>
    <a href=login.php>Sign in</a><br>
    <a href=cp.php>Control Panel</a>
    Kinda Cool...No need to change anything in the files.
    Start at login.php


  2. #2
    Fuck you, I'm a dragon Pieman is offline
    MemberRank
    Apr 2005 Join Date
    The NetherlandsLocation
    7,414Posts

    Re: [PHP] Cool Cookie Login/Logout/Control Panel

    This is truly dreadful code.

    How about you actually learn php before you go around teaching people about it.

  3. #3
    Proficient Member AngryCat is offline
    MemberRank
    Jun 2007 Join Date
    *care*Location
    196Posts

    Re: [PHP] Cool Cookie Login/Logout/Control Panel

    Quote Originally Posted by Pieman View Post
    This is truly dreadful code.

    How about you actually learn php before you go around teaching people about it.
    you know,,
    I can't agree more with you ,, :P

  4. #4
    Hm. foxx is offline
    MemberRank
    Sep 2006 Join Date
    Czech RepublicLocation
    5,257Posts

    Re: [PHP] Cool Cookie Login/Logout/Control Panel

    lmfao.. That's a piece of shat

  5. #5
    Proficient Member AngryCat is offline
    MemberRank
    Jun 2007 Join Date
    *care*Location
    196Posts

    Re: [PHP] Cool Cookie Login/Logout/Control Panel

    and just because I want, I'm gonna edit this and make it abit better :P

    PHP Code:
    <?php

    $do 
    = (isset($_GET['do']) ? $_GET['do'] : "0");

    if(
    $do == '0') {
    echo 
    '
    <form action='
    ?do=1' name='login' method='post' enctype='multipart/form-data'>
        User <input type='
    text' name='user'><br>
        Pass <input type='
    password' name='pass'><br>
        Email <input type='
    text' name='mail'><br>
        <input type='
    submit' value='Login'>
    </form>
    '

    } elseif(
    $do == '1') {

    $username 'AngryCat';
    $password md5('mysecretpassword');

    $user2 $_GET['user'];
    $pass2 md5($_GET['pass']);
    $email $_GET['mail'];

    if(
    $user2 != $username) {
    echo 
    'Wrong Username';
    exit();
    }
    if(
    $pass2 != $password) {
    echo 
    'Wrong Password';
    exit();
    }
    setcookie("user"$user2time()+3600);
    setcookie("pass"$pass2time()+3600);
    setcookie("mail"$emailtime()+3600);

    echo 
    '<html>';
    echo 
    '<body>';

    if (isset(
    $_COOKIE["user"]))
      echo 
    "Welcome " $_COOKIE["user"] . "!<br />";
    else
      echo 
    "Welcome Guest!<br />";

    if (isset(
    $_COOKIE["mail"]))
      echo 
    "Your Email is " $_COOKIE["mail"] . "!<br />";
    else
      echo 
    "No Email<br />";

    echo 
    '
    <br><b><a href="?do=2">Logout</a>
    <br><b><a href="?">Sing In</a></b>
    <br>Refresh For your information to appear.
    </body>
    </html>
    '
    ;
    } elseif(
    $do == '2') {

    <?
    php 
    setcookie
    ("user"$usertime()-3600);
    setcookie("pass"$pass2time()-3600);
    setcookie("mail"$emailtime()-3600);

    echo 
    '
    You are now logged out out.<br><b>
    <a href="?">Sign in</a><br>
    '
    ;

    }
    PS: might not work, did this in 2 min :P

    And Daevius, if this isn't allowed, I'm sorry, I just had to :P

  6. #6
    Gamma Daevius is offline
    MemberRank
    Jun 2007 Join Date
    NetherlandsLocation
    3,252Posts

    Re: [PHP] Cool Cookie Login/Logout/Control Panel

    Quote Originally Posted by AngryCat View Post
    And Daevius, if this isn't allowed, I'm sorry, I just had to :P
    ^^, you're perfectly safe.

    I would, however, add AStyle indention, but thats just preference ;)

  7. #7
    :-) s-p-n is offline
    DeveloperRank
    Jun 2007 Join Date
    Next DoorLocation
    2,098Posts

    Re: [PHP] Cool Cookie Login/Logout/Control Panel

    Cookies are useless.. Using a get method on a login makes users feel insecure when they see their password sitting up in the address bar.. Any spyware on the user's computer will get them hacked.. That's why cookies are overrated.. Use a session, and use post method...

    Also, Something similar to mcrypt_encrypt($password,password) isn't that hard of a line to write.
    My syntax isn't really right, but here:
    http://www.php.net/manual/en/functio...pt-encrypt.php
    Last edited by s-p-n; 02-08-08 at 10:56 AM. Reason: added link to PHP.net

  8. #8
    Gamma sutsurikeru is offline
    MemberRank
    Mar 2004 Join Date
    notchan/4chanLocation
    3,388Posts

    Re: [PHP] Cool Cookie Login/Logout/Control Panel

    Im using sessions aswell - alot safer

  9. #9
    Fuck you, I'm a dragon Pieman is offline
    MemberRank
    Apr 2005 Join Date
    The NetherlandsLocation
    7,414Posts

    Re: [PHP] Cool Cookie Login/Logout/Control Panel

    Quote Originally Posted by s-p-n View Post
    Cookies are useless.. Using a get method on a login makes users feel insecure when they see their password sitting up in the address bar.. Any spyware on the user's computer will get them hacked.. That's why cookies are overrated.. Use a session, and use post method...

    Also, Something similar to mcrypt_encrypt($password,password) isn't that hard of a line to write.
    My syntax isn't really right, but here:
    http://www.php.net/manual/en/functio...pt-encrypt.php
    I don't entirely agree with you, cookies can be safe but most people have no clue how to do this and just store plain passwords in cookies. Also, most people don't have a clue of when to use cookies. Cookies should only be used when things should be stored client side over a prolonged period of time.

    I myself only use cookies for the "Remember me" option on my blog.



Advertisement