I would like to set a cookie when which read back will kick off some conditional code.
setcookie() must be declared prior to <html> and <body>
The issue I am coming up against is that the Page Template declaration must be the first thing on the template. And therefore, header information has already been sent to the browser.
How should I go about coding this?
cheers!
ok, I placed my code in the header.php and do a is_page() to set the cookie.
still when I try to read it back I continually get a 'false' read rather than a 'true'.
thoughts?
error msg: PHP Warning: Cannot modify header information - headers already sent...
Just put the error message in the search box...
ok. that didnt help, but I seem to have fixed the error.
Now there is no error, but the cookie is not being set.
my code (in first line of header.php):
<?php if(is_page(139)){
setcookie ("canDownload", "yes", time()+60*60*24*365*5);
}
?>
solution: used dojo
super easy.
dojo.require("dojo.io");
dojo.io.cookie.set("canDownload","yes",365);