Tag Archives: Coding

Setting a cookie value immediately – PHP

The way to set a cookie:

setcookie("COOKIE NAME", "COOKIE VALUE", time() + 3600 * 8 * 7);

This cookie will be in place when the page next refreshes/loads;

To work with an immediate value of the cookie, add this as well:

setcookie("COOKIE NAME", "COOKIE VALUE", time() + 3600 * 8 * 7);

Using the above method will shove the value of the cookie into the session variable version, as well as writing it where it should be ready for a page reload.

Share this post:
read more