I am using this code to set a cookie and then see if they exist
setcookie(\"token\", \"value\", time()+60*60*24*100, \"/\");
setcookie(\"secret\", \"value\",
setcookie
only defines a cookie to be sent along with the rest of the HTTP headers, and they can be accessed on the next page load with the $_COOKIE
. With your code, the HTTP headers are not be sent.
You just need setcookie
when a cookie is not set. Like:
if (!isset($_COOKIE['token'])) {
setcookie("token", "value", time()+60*60*24*100, "/");
}