I'd like to be able to assign a cookie with the value of a variable, and then be able to call that cookie with the variable.
$var = "somevariable"; // from database setcookie($var, $value);
How would I refer to it?
setcookie($$var, $value); to set and $_COOKIE[$$var]; to access.....I think🙂
although, i believe the cookie won't be "available" until you load/reload/refresh the page or any other page.
ok - well I guess it works:
$var = "cookiename";
if($COOKIE["$$var"]) { echo $COOKIE["$$var"]; setcookie("$$var", "", time() - 3600); } else { if(setcookie("$$var", "test") == TRUE) { echo "cookie set"; } }