cookie cannot be set
-
Have
WP_DEBUGenabled. Since the last update (4.3.1), I’m getting thedebug.logsteadily filled with these:PHP Notice: wp_woocommerce_session_e03d1d1db669f41e7a75325c178ba160 cookie cannot be set - headers already sent by on line 0 in /wp-content/plugins/woocommerce/includes/wc-core-functions.php on line 1039After some debugging, the premature headers seem to originate from
/wp-cron.php.The fix that’s working for me is in
woocommerce\includes\wc-core-functions.php line 1036to add a check for whenDOING_CRON(and think perhaps forDOING_AJAX, too):function wc_setcookie( $name, $value, $expire = 0, $secure = false, $httponly = false ) { if ( ! headers_sent() ) { setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'woocommerce_cookie_httponly', $httponly, $name, $value, $expire, $secure ) ); #--> //} elseif ( Constants::is_true( 'WP_DEBUG' ) ) { } elseif ( Constants::is_true( 'WP_DEBUG' ) && ! defined( 'DOING_CRON' ) && ! defined( 'DOING_AJAX' ) ) { #<-- headers_sent( $file, $line ); trigger_error( "{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE ); // @codingStandardsIgnoreLine }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘cookie cannot be set’ is closed to new replies.