How To Fix Error Warning: session_start(): Cannot send session cache limiter - headers already sent
I was migrating a website from one server to another server. Once I had uploaded all the files to the new server and pulled the website, I kept getting this error at the top of the page:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/includes/myfile.php:1) in /var/www/header_file.php on line 7
when I pulled header_file.php, I had this on line 7:
I searched google to see if could find the answer, on one forum I found this thread that said to move the session_start(); to the very top like on line 2 after the
So i did that and it worked, I didn't get the error anymore. But I still questioned as to why it worked on the other server without any errors. The only think I could think of is that on of the includes files i had between line 2-7 had to have a character in the code...
You see, The RULE is you cannot have anything before the session_start(); NOT ONE CHARACTER, otherwise, the browser thinks the webpage has already started, so before you start session_start(); YOU CANNOT START THE HEADER. You start the header with any character, this includes white spaces (space bar)
So I looked in all my include files and sure enough, there was a space before the "
Bottom line is, you can't have any characters display before the session_start() function, otherwise you will get this error.
Hope his helps