Need a little help please underestanding these cookies.
| From: | Robert Chalmers | Date: | Mon, 07 Feb 2000 05:55:20 +0000 |
| Subject: | Need a little help please underestanding these cookies. | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-9897@lists.php.net to get a copy of this message | ||
I'm using php4, but still using php3 as the file type.. too many to change
:-)
anyway,
I have this cookie code, in 'cookie-set.php3' . It "seems" to be right,
according to the specs... but, down the bottom, where it echos the actual
cookie that has been set, it never shows me the affiliate code. Only ever
the randomvalue that is set if no affiliate code is entered..
<?
// Grab the affiliate code, if there is one, sent by the URL.
$affiliate = $affval;
// set cookie, affid, if not already set
if (!isset($affid))
// then, check if there is a code being sent by the url.
if (isset($affiliate))
// and set the cookie to the value of the affiliate's code
setcookie("affid",$affiliate,time()+14400,"/",".chalmers.com.au",0);
}
else {
// if there is _no_ affiliate code being sent, set the
cookie to a random value for the id.
srand((double)microtime()*1000000);
$randval = rand();
setcookie("affid",$randval,time()+14400,"/",".chalmers.com.au",0);
}
}
// check what has been set in this session
if (isset($affiliate)) {
echo "The URL has $affiliate set<br>\n";
}
if (isset($affid))
$id = $HTTP_COOKIE_VARS["affid"];
echo "The Cookie ID: $id\n";
}
?>
Then I try to remove the cookie, in cookie-clear.php3, but printing the
value, shows the value stilll hanging around?
<?
// It clears out the cookie set earlier.
setcookie("$affid","",time()+14400,"/",".chalmers.com.au",0);
$affid = $HTTP_COOKIE_VARS["affid"];
echo "Cookie value now reset: $affid\n";
?>
~
Can some kind soul tell me what I am doing wrong here please.... or am I
seeing things in my old age!
Thanks a lot,
Robert
http://www.chalmers.com.au Clipart And Books
Art, Design and Graphics.