I can't get cookie value after set it .
Notice: Undefined index: posts_notification
while it's set.
functions.php :
add_action( 'init', 'my_setcookie_example' );
function my_setcookie_example() {
if (!isset($_COOKIE['posts_notification'])){
setcookie( 'posts_notification', 'value', time() + 60,COOKIEPATH, COOKIE_DOMAIN);
}
}
// The problem is here :
print_r($_COOKIE['posts_notification'] );
i should refresh 2 time to get this value !!!