Try this, sets cookie
$time=time();
setcookie("test", "value", time()+86400);
The time can be adjusted it's set for one day before it expires.
To read the cookie
$varname = $_COOKIE["test"];
echo $varname;
It should echo out value
since that is the example data your setting in cookie.
You can also use the same name for setcookie
to override your existing value