Getting headers already sent error from plugin

If you look at the source of the page you will see this around line 122:

<div class="nav-collapse collapse">
                    <br />
<b>Warning</b>:  session_start() [<a href="https://wordpress.stackexchange.com/questions/105453/function.session-start">function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /home1/onesizeu/clients/instrumentalbackgroundmusic.com/wp-includes/functions.php:2841) in <b>/home1/onesizeu/clients/instrumentalbackgroundmusic.com/wp-content/plugins/osu-royaltfreemusic/osu-royaltyfreemusic.php</b> on line <b>225</b><br />
<br />
<b>Warning</b>:  session_start() [<a href="https://wordpress.stackexchange.com/questions/105453/function.session-start">function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /home1/onesizeu/clients/instrumentalbackgroundmusic.com/wp-includes/functions.php:2841) in <b>/home1/onesizeu/clients/instrumentalbackgroundmusic.com/wp-content/plugins/osu-royaltfreemusic/osu-royaltyfreemusic.php</b> on line <b>225</b><br />
<ul id="menu-primary" class="nav"><li id="menu-item-9" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-9"><a href="http://www.instrumentalbackgroundmusic.com/">Home</a></li>

Something is trying to start a session well into the body of the page. You can’t do that. Sessions need to be started before any content is sent to the browser.

The fix for this is conceptually simple– hook the session_start function to some hook that runs before content is printed. Something like this:

function boot_session() {
  session_start();
}
add_action('wp_loaded','boot_session');

I don’t know what, exactly, is calling session_start or why, so the practical fix may be more complicated but that is the basic fix.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)