• Resolved Guido

    (@guido07111975)


    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 the init 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

Viewing 16 replies (of 16 total)
  • Thread Starter Guido

    (@guido07111975)

    But I may be wrong?

    It seems it’s not prohibited to use them, as discussed here. Simply not recommended.

    Guido

Viewing 16 replies (of 16 total)
  • The topic ‘Set cookie – headers already send’ is closed to new replies.