note 30136 deleted from function.setcookie by tularis
| From: | tularis@php.net | Date: | Sun, 02 Jan 2005 14:27:05 +0000 |
| Subject: | note 30136 deleted from function.setcookie by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-82598@lists.php.net to get a copy of this message | ||
Note Submitter: oz at austdesign dot co dot uk
----
I have had a similair problem with a login script using cookies on Safari on MacOS X and IE6 on
Windows XP
The original script looked like this:
----Code-----
#Encrypt Password
$password = md5($password);
if(authLogIn($username, $password)){
setcookie ('user', $username,time()+3600);
setcookie ('password', $password,time()+3600);
header ("Location: adminhome.php");
exit;
}else{
header ("Location: index.php");
exit;
}
------------------
I changed the setcookie calls to be a complete cookie and only the password was written.
I then figured out that the two browsers do not except cookies that are written directly from the
form that submitted it.
The password was encrypted so the value was different to what was on the form.
the following code is the final working version with a work around to get the username to be written
to a cookie:
-----code-----
#Encrypt Password
$password = md5($password);
$user = $username;
if(authLogIn($username, $password)){
setcookie ('user', $user,time()+3600,
'/','www.siteaddress.co.uk');
setcookie ('password', $password,time()+3600,
'/','www.siteaddress.co.uk');
header ("Location: adminhome.php");
exit;
}else{
header ("Location: index.php");
exit;
}
----------------