Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
2  
yes you are. Try to find out the actual problem and why the plugin sets cookies after headers have been sent –  onetrickpony Apr 25 '12 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()
{
    ob_start();
}

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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