I'm having a bit of trouble with a 'headers already sent' error from a Wordpress plugin I had built for me and now I'm adapting. This is the error:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home1/uname/directory/domain.com/wp-content/themes/ibm/header.php:2) in /home1/uname/directory/domain.com/wp-content/plugins/osu-rfm/osu-rfm.php on line 225

I've looked at header.php line 2 and this is what is there with no extra white spaces nor funny characters etc:

<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="ie ie6 no-js" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 7 ]>    <html class="ie ie7 no-js" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 8 ]>    <html class="ie ie8 no-js" <?php language_attributes(); ?>> <![endif]-->
<!--[if IE 9 ]>    <html class="ie ie9 no-js" <?php language_attributes(); ?>> <![endif]-->
<!--[if gt IE 9]><!--><html class="no-js" <?php language_attributes(); ?>><!--<![endif]-->
<!-- the "no-js" class is for Modernizr. -->

<head id="osu-rfm" data-template-set="html5-reset-wordpress-theme" profile="http://gmpg.org/xfn/11">

              if (function_exists('is_tag') && is_tag()) {
                 single_tag_title("Tag Archive for &quot;"); echo '&quot; - '; }

I've looked at line 225 in osu-rfm.php and this is what is part of that file (this is the plugin btw):

public static function enable_sessions()
    if( is_post_type_archive( "ibmdirectory" ) || "ibmdirectory" == get_post_type() )
        if( ! isset( $_SESSION ) )
    if(headers_sent($filename, $linenum)) {
        //if headers already sent out print some message.
        echo "Headers already sent in $filename on line $linenum\n";
    } else {
        //if headers not already sent
        echo "New headers";

And now I'm completely stuck as I don't know what to try next...can anyone make some suggestions? I removed all white space at the end and beginning in all my theme files as suggested here, but it doesn't seem to make a difference. I've also tried removing the closing ?> tag at the end of my plugin file, but nada.

By the way, this only happens on my live server, not my local set up, so I have the feeling it could be a server issue.



  • Post the first 10 or so lines of header.php
    – s_ha_dum
    Jul 5, 2013 at 14:17
  • Hi @s_ha_dum thanks for responding - original question updated as requested
    – Osu
    Jul 5, 2013 at 14:22
  • That file should be sending output. That is not the problem. Turn debugging off. Do you still have the problem?
    – s_ha_dum
    Jul 5, 2013 at 14:27
  • This is how my debugging is set up in wp-config.php : define('WP_DEBUG', false); - I assume you meant that rather than php.ini?
    – Osu
    Jul 5, 2013 at 14:29
  • What is the URL to the live site?
    – s_ha_dum
    Jul 5, 2013 at 14:32

1 Answer 1


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='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='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() {

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.