My wordpress plugin uses sessions for handling various things, and on the production site I'm testing it on output buffering is not on by default so I'm getting a lot of messages such as these:

Warning: session_start() [function.session-start]: 
Cannot send session cookie - 
headers already sent by 
(output started at /blah/wp-content/themes/Starkers/header.php:12) 
in /blah/wp-content/plugins/rsq/store.php on line 4

Is there a hook or something I can latch on to in order to turn on output buffering? Am I going about this in entirely the wrong way?

Thanks, John.

  • 2
    yes you are. Try to find out the actual problem and why the plugin sets cookies after headers have been sent Commented Apr 25, 2012 at 11:39

1 Answer 1


Although I realise this is probably not the right way to go about it, I managed to turn on output buffering using the following code in my plugin:

add_action('init', 'rsq_buffering');
function rsq_buffering()

I probably should be doing any session stuff from within the init hook instead of just all over the place.

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.