1

I knew that this question may mark as duplicate but I can't find my answer from any duplicated post so I decided to post it in my own.

I have a Pages with a session. after all task, there is a button that link into this controller called Profileresult.php but even I do not have a code yet its surprising me that I got this error.

here is the error.

A PHP Error was encountered

Severity: Warning

Message: session_start(): Cannot send session cache limiter - headers already sent (output started at /home3/oep2732/public_html/knowyourscore/application/controllers/Profileresult.php:1)

Filename: Session/Session.php

Line Number: 140

Backtrace:

File: /home3/oep2732/public_html/knowyourscore/index.php Line: 315 Function: require_once

I created a controller called Profileresult.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Profileresult extends CI_Controller {


    public function index()
    {
    }

}

?>
Mc Gyver Basaya
  • 143
  • 6
  • 16
  • make sure you have not an empty space before the start of php tag or just put ob_start() in beginning of php code – Aman Maurya Aug 08 '16 at 10:25

1 Answers1

7

Check your controller file. Remove any empty space within that file. For example:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Profileresult extends CI_Controller {
    public function index() {
         //your codes here
    }
}
?>

In your IDE, if you don't have any comment on top of <?php tag, make sure it is in line 1. No empty spaces. Same goes to at the end of ?> tag. If you have empty spaces after that. Those errors will occurs. I've encounter the same problem as yours. I tried to check my controller file as Aman Maurya said, and yes I have few lines of empty spaces. Removed that, that error not display anymore.

voloshin
  • 536
  • 7
  • 17
  • this fixed my errors thanks, but any details why it does require nothing at first line, and how did you figure it out, it would be so helpful – Ridha Rezzag May 20 '19 at 15:32
  • 1
    Hi Rida, I am not sure why but I believe below link should answer why it is happen. https://stackoverflow.com/questions/8812754/cannot-send-session-cache-limiter-headers-already-sent . How I figured out? I read Aman Maurya comment and tried clear out any empty spaces at the top and at the end of my php file, then the error was gone when refreshed. – Muhammad Hafiz Hussin Jun 11 '19 at 02:28
  • This answer really helped me. I could not imagine even one space can create an error. Thanks for your answer. :) – disha Jun 03 '20 at 06:22