Cannot send session cache limiter

I had my web host move my site to another server. All looks well upon testing, but when I return from a test payment, from Paypal, I see this warning at the top of the page. I don’t know what it means. Can you enlighten me as to what it means and how I might remedy it?
Thanks

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/public_html/payment/paypal_success.php:2) in /home/public_html/classes/config.php on line 19

This means that you have outputted some char or chars before setting the session.

Usually it is a line feed or space before <?php or an echo statement before starting the session.

In other words, something is sent to the browser before line 19.

Quick solution: put ob_start() at the top of your script to enable output buffering, this allows you to send headers whenever you like without seeing any silly php errors.

payment.php:


<?php ob_start(); ?>
.... the rest of your html / php code.

better if you end with ob_end_clean(). so full code looks like:


<?php ob_start(); ?>
.... the rest of your html / php code.
<?php ob_end_clean(); ?>

Better when you like to write more code. Calling ob_end_clean is redundant, there is built-in automatic buffer flush, at the end of script execution any buffer contents will be automatically flushed.

Ho ho ho! It is not only redundant, but it can lead you to errors! You mistyped the function, ob_end_clean() does not flush the buffer, the function you were thinking of is ob_end_flush(): http://php.net/ob_end_flush . Nice catch!

if you forgot to write proper php tags like:
?php
//php code here…
?>
it will give error. So don’t use PHP. :wink:

Just a humor.

BTW you cannot say like that.

Anyway thanks for the info:

ob_end_flush() isn’t needed in MOST cases because it is called automatically at the end of script execution by PHP itself when output buffering is turned on either in the php.ini or by calling ob_start().

using ob_ is quick but dirty.
and it won’t help if there is BOM

it is much better to sort things out and include paypal script in the proper place.
and it is not silly PHP errors but silly PHP programmer, who can’t handle his output in a proper way :slight_smile:

So whats the proper way of handling output?

with two hands :slight_smile: joke

Your app must be divided, frankly, to the two parts:
Logic part and output part.
Any output must be done by some template system only. No direct output at all.
It will help you in thousands ways. changing template system or implementing HTTP caching are examples.

oops