note 68495 deleted from function.setcookie by betz

From: Date: Sun, 30 Jul 2006 13:13:52 +0000
Subject: note 68495 deleted from function.setcookie by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-115345@lists.php.net to get a copy of this message
Note Submitter: bret ---- i have a problem with my set cookie code it just isnt working.. please help me if u can: } if ($_POST[login]) { // the form has been submitted. We continue... $username=$_POST['username']; $password = md5($_POST[password]); // the above lines set variables with the submitted information. $info = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); $data = mysql_fetch_array($info); if($data[password] != $password) { // the password was not the user's password! echo "Incorrect username or password!"; }else{ // the password was right! $query = mysql_query("SELECT * FROM users WHERE username = '$username'") or die(mysql_error()); $user = mysql_fetch_array($query); // gets the user's information setcookie("id", $user[id], time()+3600); /* expire in 1 hour */ setcookie("pass", $user[password], time()+3600, "/~rasmus/", ".bretx-designs.x1topsites.com", 1); // the above lines set 2 cookies. 1 with the user's id and another with his/her password. echo ("Thank You! You will be redirected"); // modify the above line...add in your site url instead of yoursite.com } } } else { // we now display the user controls. echo (" Welcome $logged[username] - <a href=\"editprofile.php\">Edit Profile - <a href=\"members.php\">Member List - <a href=\"logout.php\">Logout"); } ?>

« previous php.notes (#115345) next »