Rick
|
| Posted: 04/18/2002, 7:36 AM |
|
I'm using the following code snippet. I have no problems with creating the cookie, but can't get my php page to read the cookie the next time I visit the site. Anyone see what I'm doing wrong?
$nextyear = mktime (0,0,0,date("m"), date("d"), date("Y")+1);
if (isset($cookieValue)){ // check to see if cookie exists
//cookie exists... get value
$value = $cookieValue;
}
else{ //cookie does not exists so set cookie and value to default
setcookie("cookieValue", "Default", $nextyear);
$value = "Default";
}
$tpl->set_var("value", $value);
Thanks,
Rick
|
|
|
 |
Nicole
|
| Posted: 04/19/2002, 1:16 AM |
|
Rick,
as you know cookies must be sent before any other headers are sent. So you can put your code into page open event only. But you cannot use set_var function there, because template isn't loaded yet.
To verify cookie value use:
echo "cookie: ". $cookieValue. "<br>";
global $HTTP_COOKIE_VARS;
echo "cookie: ". $HTTP_COOKIE_VARS["cookieValue"]. "<br>";
It shouldn't be empty.
|
|
|
 |
Rick
|
| Posted: 04/23/2002, 8:08 AM |
|
Thanks Nicole.
All is well in cookie land.
Rick
|
|
|
 |
|