/*******************************************************************************
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 here:
http://developer.netscape.com/docs/manuals/js/client/jsref/cookies.htm
This user function is written to mimic the built-in setcookie() function in
PHP, 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;
}