So I'd rather not use JS/jQuery for this - but I can't seem to get this to work.
I've got a link <a href="?hideupdates=hide">Hide Updates</a>
which I'm trying to set a cookie with.
if($_GET['hideupdates'] == 'hide'){
setcookie("HideUpdates", "hide", time()+60*60*24*5, "/", $vars->networkSite);
}
it "works", but I have to click the link twice.
from "site.com" I can var_dump()
the cookie and it comes up NULL
Now I click the link and go to "site.com?hideupdates=hide" and the cookie still comes up NULL
However, from "site.com?hideupdates=hide" when I click the link again - THEN the cookie comes back hide
.
Am I missing something? Or do I 'have' to use JS/jQuery for this?
setcookie
does not affect the current request. To do that, you also need to manually set the relevant $_COOKIE
variable:
setcookie("HideUpdates",$_COOKIE['HideUpdates'] = "hide", time()+60*60*24*5, "/", $vars->networkSite);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With