tags:

views:

56

answers:

4

I have some code which works fine on one server but is giving a session header warning:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent

on another.

I have checked the php.ini settings on the two servers and they are identical.

I know that the warning message is supposed to suggest that something has been outputted before the session_start but what I don't understand is why the same code works on one server but not the other.

Is there anything else that could be explaining it other than the php.ini settings?

+2  A: 

Possibly in the transfer of files to the second server you introduced blank lines at the end of one of your files?

Scott Wilson
+1  A: 

I have checked the php.ini settings on the two servers and they are identical.

I think you're wrong, and one of them has buffering on.

Col. Shrapnel
OK, let me clarify. I checked the "Session" settings in php.ini and they were identical. You are correct that if I set the buffering to On the problem goes away. What is the wider consequences of doing this?Thanks
williamsdb
@william The only consequence is the fact that you write a spaghetti code, unstructured and messy. In the properly planned code it's just impossible to have an HTTP header sent after HTML output started.
Col. Shrapnel
A: 

Have you checked the web server's configuration as well? php directives can be set in Apache's httpd.conf and .htaccess files, and you'd end up with differences, even though the main php.ini files are identical.

What you should do is compare the output of phpinfo() on both servers. If there are any differences in server configuration, that's where it would show up.

Marc B
A: 

perhaps some invisible characters got at the beginning of one of your files during transfer or whatever

Dominik