kylephillips / favorites

Simple and flexible favorite buttons for any WordPress post type.
https://favoriteposts.com
223 stars 86 forks source link

PHP Warning: session_start(): Cannot start session when headers already sent #146

Closed okwasniewski closed 3 years ago

okwasniewski commented 3 years ago

Hello,

I have installed the plugin everything works seamlessly but there is one problem that stops the site from responding.

04-Jan-2021 07:50:16 UTC] PHP Warning: session_start(): Cannot start session when headers already sent in /home/joganika/public_html/wp-content/plugins/favorites/app/Bootstrap.php on line 83 [04-Jan-2021 07:55:14 UTC] PHP Warning: session_start(): Cannot start session when headers already sent in /home/joganika/public_html/wp-content/plugins/favorites/app/Bootstrap.php on line 83

The error is generated over and over which causes the site to freeze and don't load.

genesanchez commented 3 years ago

I too have this issue. I have found a workaround for my setup. Since I don't use Anonymous users on my env. I changed the Plugin Favorites settings : Users : Save Unauthenticated Favorites as to Cookie instead of session. It seems to solved my problem. It may not apply to your setup. I just wanted to share my experience if you want to give it a try.

okwasniewski commented 3 years ago

@genesanchez Thanks, this resolved the issue for me.

sz-33 commented 3 years ago

Hello, if we replace

if ( !session_id() ) session_start();

by

session_start(['read_and_close' => true,]);

it seems to work

++