Sto provando a impostare un cookie in wordpress. Ho il mio biscotto impostato in questo modo:Come impostare un cookie in Wordpress
<?php setcookie('test', 'test', 0, '/', '/'); ?>
in header.php del mio tema, ma quando vado al mio browser per vedere il mio sito ho ottenere questo errore
Warning: Cannot modify header information - headers already sent by (output started at /home/content/19/9468119/html/wp-content/themes/twentyeleven/header.php:27) in /home/content/19/9468119/html/wp-content/themes/twentyeleven/header.php on line 201
e anche il mio biscotto doesnt impostato. Come posso impostare un cookie in wordpress?
Ho anche provato questa
function set_new_cookie() {
setcookie('test', 'test', 0, '/', '/');
}
add_action('init', 'set_new_cookie');
in WordPress, si dovrebbe usare '' COOKIEPATH' e COOKIE_DOMAIN', altrimenti si rischia di avere problemi con i biscotti di lavoro corretto (vedi [questa risposta] (http://stackoverflow.com/a/ 30665891/870729)) –