PHP Error - "Cannot send session cache limiter - headers already sent" - A Solution
PHP Error - Cannot send session cache limiter - headers already sent - Finally, a solution!
This error seems to be a very common one and the only solution usually offered across the Internet is this:
- Make sure to check for and remove any spaces or carriage returns directly before or after your opening and closing php tags.
This problem persisted for me one time and after trying the above recommended solution with no success, I was still scratching my head as to what else may be the problem.
Then, I started thinking about how different code editors can add extra code and spaces into your file without your knowledge so I thought I would investigate that some more. I already was using a pure-text editor, so I knew that it wasn't injecting garbage code into my existing code like a WYSIWYG editor may do. So, I started poking around my settings and preferences and found something that I had overlooked many times before in my search... The files could be saved in different encoding formats, such as UTF-8. Depending on the server configuration where the files live, this setting can have a huge impact when it comes to sensitive functions such as creating a session or setting a session variable.
On a whim, I decided to change the default setting of UTF-8 to ANSI and Lo and Behold, it miraculously started working again.
So, I offer this solution to those who have tried everything else to correct the headers slready sent error:
- Change the encoding type/format to ANSI (or UTF-8, UNICODE, etc.), then save the file to the server again and reload the page once more. This worked for me when nothing else would.
I hope this has been helpful for some if you out there. If you ever need someone to do some PHP coding for you or someone you know, I would appreciate the referral.
Take care,
Alan
