note 20911 added to function.setcookie

From: Date: Sun, 21 Apr 2002 11:39:08 +0000
Subject: note 20911 added to function.setcookie
Groups: php.notes 
Request: Send a blank email to php-notes+get-29637@lists.php.net to get a copy of this message
/************************************************************ FUNCTION SEND_HTCOOKIE Author: Van Carney (van@Webfreshener.com) ©2000-2002 Webfreshener.com last rev: 4/21/02 3:56:47 AM HTTP Cookie generation routine takes variable number of args and writes cookie to header per the Netscape Cookies Spec This user function is written to mimic the built-in setcookie() function in PHP. This was done as problems were noticed with that function when writing cached cookies from within Object Scopes. PHP would not write a cached cookie when setcookie() was called inside an object. This function has been tested and workes quite nicely in multiple scopes. usage: send_htCookie(string varname (required),string varval,string 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)) { $COOKIE .= "; EXPIRES=$expire";} if (isset($domain)) { $COOKIE .= "; DOMAIN=$domain"; } if (isset($path)) { $COOKIE .= "; PATH=$path"; } if (isset($secure) && $secure>0) { $COOKIE .= "; SECURE"; } header($COOKIE); return true; } -- http://www.php.net/manual/en/function.setcookie.php http://master.php.net/manage/user-notes.php?action=edit+20911 http://master.php.net/manage/user-notes.php?action=delete+20911 http://master.php.net/manage/user-notes.php?action=reject+20911

« previous php.notes (#29637) next »