• Resolved timholz

    (@timholz)


    Hi – in functions.php right at the start, i am setting a cookie like that:

    add_action( 'init', 'toa_setcookie' );
    function toa_setcookie() {
    if (!isset($_COOKIE['sid'])){
    setcookie("sid", time(), 0, COOKIEPATH, COOKIE_DOMAIN);
    }
    }

    With litespeed plugin enabled i get a warning in debug.log:

    Warning: Cannot modify header information - headers already sent etc.

    With litespeed disabled there is no warning. Is there a way to use cookies with litespeed without warning? Some action to hook into? thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support qtwrk

    (@qtwrk)

    yes, because our plugin need to send out cache/purge header to instruct webserver

    if you are also sending header, it will end up like this

    please try hook into send_header() , see if it helps , e.g.

    add_action('send_headers', 'toa_setcookie');
    function toa_setcookie() {
    setcookie(......);
    }
    Thread Starter timholz

    (@timholz)

    Thank you for suggesting ‘send_headers’. I made some tests and it seems to be the appropriate hook. The warning does not appear any more. Regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘“Headers already sent” warning in debug.log with litespeed’ is closed to new replies.