Set cookie – headers already send
-
Hi,
I set a cookie like this:
function my_cookie() { setcookie( 'my_cookie', 'my_value', 0, COOKIEPATH, COOKIE_DOMAIN); } add_action( 'init', 'my_cookie' );
Seems to work but client reported the “Cannot modify header information – headers already sent” error. Apparently another plugin or his theme is sending output before headers are send. I can try the
send_headers()
hook but notice this one is loaded after theinit
hook. So don’t think this will fix his problem.Is there a way to fix this without knowing the behavior of other plugins/themes?
Guido
- The topic ‘Set cookie – headers already send’ is closed to new replies.