Justin Mercado Justin Mercado - 1 year ago 50
PHP Question

Session start on an empty page causes an error; session_start(): Cannot send session cache limiter

Hi I have a php file that is empty and the only line of code in there is

<?php session_start(); ?>

No html mark-up or any php code besides the code above.

On localhost it doesn't trigger an error, but when it's on the server and I visit the page, a new line is printed on the error log that says

[25-Apr-2016 05:43:34 UTC] PHP Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at path/to/file.php:1) in /path/to/file.php on line 1

The server is running apache and php 5.6 if that's relevant, I've also tried deleting the .htacces file just in case that is what's causing the problem but still no luck.

Can anyone point me in the right direction to see what may be causing the issue? Thanks!


Problem : Sometimes there are invisible characters inside your code file.

Solution : So simply for now if want to fix the error so here is the quick way to do it : I am sure you must be using some sort of Code Editor just simply save your php file with encoding as "UTF-8 With BOM" and then upload the saved file to your site and then access your file and you will have no problem..!

Screenshot For Better Guidance : enter image description here

Reference URL :

How to fix "Headers already sent" error in PHP

If that doesn't solve your problem so then use this solution :

  1. Make sure there is absolutely no whitespace before <?php
  2. Put session_start() before ob_start() instead of after it.
  3. If that fails, try commenting out the session_start() as one of your includes might already be starting the session, like so: /** session_start(); **/