Re: setcookie()
| From: | Casey Allen Shobe | Date: | Sun, 06 Jan 2002 21:44:07 +0000 |
| Subject: | Re: setcookie() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-79623@lists.php.net to get a copy of this message | ||
Here's a compilation of some recent conclusions I've gotten from the same
discussion:
This is how I chose to set the variables:
// $username and $password are passed from a previous page's form.
$time = mktime()+1800;
$date = gmdate("D, d-M-Y H:i:s", ($time));
$password = md5 ($password);
header ('Set-Cookie: username='.$username.'; expires='.$date.' GMT; path=/;
domain='.$SERVER_ADDR);
header ('Set-Cookie: password='.$password.'; expires='.$date.' GMT; path=/;
domain='.$SERVER_ADDR);
Produces:
Set-Cookie: username=Rasmus; expires=Wed, 12-Dec-2001 21:58:55 GMT; path=/;
domain=www.php.net
Set-Cookie: password=d41d8cd98f00b204e9800998ecf8427e;
expires=Wed, 12-Dec-2001 21:58:55 GMT; path=/; domain=www.php.net
Whereas these two calls (per Rasmus Lerdorf):
SetCookie('username',$username,time()+1800,'/',$SERVER_ADDR);
SetCookie('password',$password,time()+1800,'/',$SERVER_ADDR);
Produce:
Set-Cookie: username=Rasmus; expires=Wed, 12-Dec-01 21:58:55 GMT; path=/;
domain=www.php.net
Set-Cookie: password=d41d8cd98f00b204e9800998ecf8427e;
expires=Wed, 12-Dec-01 21:58:55 GMT; path=/; domain=www.php.net
Putting them side by side to make it easier to compare:
Set-Cookie: username=Rasmus; expires=Wed, 12-Dec-2001 21:58:55 GMT; path=/;
domain=www.php.net
Set-Cookie: username=Rasmus; expires=Wed, 12-Dec-01 21:58:55 GMT; path=/;
domain=www.php.net
Ramsus wrote:
> They are identical except for the PHP SetCookie() version using a 2-digit
> year (which can be changed in your php.ini file with the y2k directive).
--
Casey Allen Shobe
cshobe@softhome.net
'Why do people with closed minds always open their mouths?'