note 21155 added to function.setcookie
| From: | regina at hitel dot net | Date: | Wed, 01 May 2002 09:24:32 +0000 |
| Subject: | note 21155 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-30038@lists.php.net to get a copy of this message | ||
Thanks to Van Carney.
But, that function has a little problem in PHP 4.2.0.
So, I did re-write it, below.
/******************************
ysage:
send_htCookie(string varname (required),string varval,int expire,
string path, string domain, bool secure);
******************************/
function send_htCookie() {
$vars=array('varname','varval','expire',
'path','domain','secure');
for ($i=0;$i<func_num_args();$i++) {
${$vars[$i]}=func_get_arg($i);
}
if (!$varname) { return false; }
$COOKIE = "Set-Cookie: $varname=$varval";
if (isset($expire) && ($expire > 0)) {
$COOKIE .= "; EXPIRES=".
gmdate("D, d M Y H:i:s",$expire) .
" GMT";}
if (isset($domain)) { $COOKIE .= "; DOMAIN=$domain"; }
if (isset($path)) { $COOKIE .= "; PATH=$path"; }
if (isset($secure) && $secure>0) { $COOKIE .= "; SECURE"; }
header($COOKIE,false);
return true;
}
--
http://www.php.net/manual/en/function.setcookie.php
http://master.php.net/manage/user-notes.php?action=edit+21155
http://master.php.net/manage/user-notes.php?action=delete+21155
http://master.php.net/manage/user-notes.php?action=reject+21155