Can't set cookie in Wordpress plugin after theme has started rendering

前端 未结 2 872
野性不改
野性不改 2021-01-25 17:22

When I set a cookie in a Wordpress plugin, I get the \"headers already sent\" error. Can someone suggest how I can fix this?

Warning: Cannot modify header

2条回答
  •  死守一世寂寞
    2021-01-25 17:47

    You can avoid header modification warning messages by buffering your source, before it makes it to the browser. If you do not have access to php.ini you can add php_value output_buffering 4096 to your .htaccess or you can add ob_start("ob_gzhandler"); at the top and ob_end_flush() at the bottom of your wordpresses root index.php

提交回复
热议问题