note 71921 deleted from function.setcookie by bjori

From: Date: Mon, 08 Jan 2007 10:56:07 +0000
Subject: note 71921 deleted from function.setcookie by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-121445@lists.php.net to get a copy of this message
Note Submitter: shahcheraghphoto at gmail dot com ---- If you want use setcookie for login(remember me cookie),you must use MD5() or Sha1() for encoding data: <?php $username = $_POST['username']; $password = sha1($_POST['password']); /* Hash the input password and check it against the already hashed password stored in the database. Since both passwords are hashed using the same hash function, the two passwords will match if the user enteres the correct password */ $user = $DB->getRow('SELECT * FROM users WHERE username=? AND password=?', array($username, $password)); if(!$user) die('Sorry, incorrect username or password.'); // Did this user check that 'remember me' checkbox? if($_POST['remember_me']) { $expire = time() + 1728000; // Expire in 20 days $cookie_pass = sha1( sha1($useSince both passwords are hashed using the same hash function, the two passwords will match if the user enteres the correct password */ $user = $DB->getRow('SELECT * FROM users WHERE username=? AND password=?', array($username, $password)); if(!$user) die('Sorry, incorrect username or password.'); // Did this user check that 'remember me' checkbox? if($_POST['remember_me']) { $expire = time() + 1728000; // Expire in 20 days $cookie_pass = sha1( sha1($user['password']) . sha1($user['salt']) ); setcookie('user', $user['username'], $expire); setcookie('pass', $cookie_pass, $expire); } ?>

« previous php.notes (#121445) next »