I try to create a cookie with data from a variable. This variable is filled on a specific blog post. What is the way to get the data from this variable and set it in the cookie?
Wordpress set cookie works only in the functions.php file.
This is what I have
function cookietime($time) {
if(!isset($_COOKIE[$wp_time])) {
// sessin cookie filled with data from $time
setcookie('wp_time', $time);
}
}
add_action('placeCookie', 'cookietime', 10, 1);
This code is writin in the functions.php
do_action('cookietime', $parameter);
//this line on the specific post