note 68495 added to function.setcookie
| From: | bret at osu1 dot php dot net | Date: | Sat, 29 Jul 2006 22:51:14 +0000 |
| Subject: | note 68495 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-115332@lists.php.net to get a copy of this message | ||
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");
}
?>
----
Server IP: 216.235.15.211
Probable Submitter: 24.222.215.148
----
X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.setcookie.php
Edit -- http://master.php.net/note/edit/68495
Del: integrated -- http://master.php.net/note/delete/68495/integrated
Del: useless -- http://master.php.net/note/delete/68495/useless
Del: bad code -- http://master.php.net/note/delete/68495/bad+code
Del: spam -- http://master.php.net/note/delete/68495/spam
Del: non-english -- http://master.php.net/note/delete/68495/non-english
Del: in docs -- http://master.php.net/note/delete/68495/in+docs
Del: other reasons-- http://master.php.net/note/delete/68495
Reject -- http://master.php.net/note/reject/68495
Search -- http://master.php.net/manage/user-notes.php