Hi,
Has anyone come across this cookie problem before?
I'm trying to update a cookie value within a switch statement, however it won't update the cookie with the new value, but if I move the setcookie statement before the switch, it works. Example:
In the switch:
switch ($testvar):
case 1:
setcookie("TestCookie","value 01",strtotime("+1 year"),"/",".mydomain.com",0);
break;
default:
// something else
break;
endswitch;
Before the switch:
setcookie("TestCookie","value 01",strtotime("+1 year"),"/",".mydomain.com",0);
switch ($testvar):
case 1:
break;
default:
// something else
break;
endswitch;
Does anyone know why this happens? I've also tried it with a Set-Cookie header statement, but the same thing happens. It also seems to happen when I call a function:
if (funValidateFields()):
setcookie("TestCookie","value 01",strtotime("+1 year"),"/",".mydomain.com",0);
endif;
function funValidateFields() {
return true;
}
If I put the setcookie either before the if or even in the function, the cookie is updated, however it isn't when setcookie appears within the if.
This has me complete foxed and I'm sure it's something simple, but I can't see the wood for trees. Can anyone suggest what I could be missing?
DebbieLeigh