I was using this code in my plugin to set a cookie if a condition was met, however after updating to Wordpress 4.0 I got the message:
Warning: Cannot modify header information - headers already sent
How can I set the cookie before headers are sent? This is my code:
// Add Cookie if Admin
if (current_user_can('manage_options') || !empty($_COOKIE["loggedAdmin"]))
{
setcookie("loggedAdmin", "true", time()+3600*24*365);
}
}
add_action('init', array('Pranalog_Analytics', 'detect_admins'));
still I keep getting that error. Also it says the input started on functions.php but I see nothing wrong there – Lisandro Vaccaro Sep 15 '14 at 18:48