0

I recently migrated from a Windows to Linux server... now I am getting a bunch of session warnings and some of the content is being loaded properly. On the Windows server, everything worked smooth and I never had any errors, as soon as the migration to Linux took place, I started getting session warnings such as the one below on every page that uses sessions.

I have no idea what I should try or where to begin to address these problems and would appreciate any advice.

I suspect that if session_start() was actully was the problem, I would have gotten a similar warning on the Windows server.

Also my site is hosted by goaddy and I do not have access to the php.ini file...

        Warning: session_start() [function.session-start]: Cannot send session
 cookie - headers already sent by (output started 
    at /home/content/12/9453412/html/mainsearch.php:32) 
    in /home/content/12/9453412/html/mainsearch.php on line 36
AnchovyLegend
  • 12,139
  • 38
  • 147
  • 231
  • 2
    You probably did not have error_reporting or display_errors turned on on the Windows server. These are not new errors... The "headers already sent" is caused by output, even just whitespace, anywhere in your code before a call that sends a header (like setcookie() or session_start()) – Michael Berkowski Aug 02 '12 at 13:43
  • Make sure you have used the exact name and not filename in any other cases – Sourav Aug 02 '12 at 13:44
  • possible duplicate of [Headers already sent by PHP](http://stackoverflow.com/questions/8028957/headers-already-sent-by-php) – Michael Berkowski Aug 02 '12 at 13:44
  • **include "file.php"** will not work if the file name is **File.php** in Linux – Sourav Aug 02 '12 at 13:45
  • @Sourav, thanks for clarifying. I am using the exact filenames for the includes. – AnchovyLegend Aug 02 '12 at 13:46
  • the warning is telling you where's the problem: mainsearch.php, line 32.. something creates output there.. you are either echoing something and on the windows server you were using output buffering (with a bigger buffer if you do on linux too) or one of the standard differences between the two create an error.. like the case sensitivity mentioned by @Sourav or files permissions – mishu Aug 02 '12 at 13:47
  • I appreciate all the help everyone, everything is up and running again :) – AnchovyLegend Aug 02 '12 at 14:05

1 Answers1

2

Your problem is, that in

/home/content/12/9453412/html/mainsearch.php line 32

(and possibly also in the following ones) you do some kind of output (echo, print, blanks outside of <?php ... ?> etc.), before you do session_start(); on line 36. This is not allowed, as session_start() wants to send headers which is not possible after some kind of output already occured.

Solution: Put your session_start(); to the top of your php file, or at least before you do any kind of output.

And Michael pointed out correctly that this didn't work correctly on you Windows server either, you just didn't know because error reporting was set not to display warnings.

MiDo
  • 1,057
  • 1
  • 7
  • 11