Answer the question
In order to leave comments, you need to log in
Problem displaying cookie value?
Hello.
The theme's functions.php file specifies the creation of a cookie:
add_action( 'init', 'create_cookie' );
function create_cookie() {
// если кукиша нет или он пустой, создаём его с дефолтным значением
if(!$_COOKIE["my_cookie"] || empty($_COOKIE["my_cookie"])) {
setcookie( 'my_cookie', 'value', time()+7776000);
};
}
if(!$_COOKIE["my_cookie"]) {
echo '0';
}
elseif(empty($_COOKIE["my_cookie"])) {
echo '1';
}
else {
echo '2';
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question