12

I have created a dynamic menu CMS website. I developed in a Windows system. When i run my project in windows operating system, My project runs without any error. But now uploaded it into Linux Operating system server i am getting warning & error like:

    A PHP Error was encountered

    Severity: Warning

    Message: Cannot modify header information - headers already sent by (output started at /home/ansofcm8/public_html/apps/resources/math/application/core/MY_Controller.php:1)

    Filename: libraries/Session.php

    Line Number: 675

What could be the reason. Please help me.

Dan
  • 2,086
  • 11
  • 71
  • 137

1 Answers1

36

There seems to be whitespace before the php open tag <?php in MY_Controller.php.

Check all PHP files and remove the whitespace before the <?php tag. If there is a space or new line, the body of the http request is started, and you can't add new headers to the http request.

JackPoint
  • 4,031
  • 1
  • 30
  • 42
  • 1
    Yep, is a whitespace. @Burls Willis check `headers already sent by (output started at MY_Controller.php:1)`. It's pointing to line 1, and the only thing that is sending something to the frontend on the first lines in a php file are whitespaces. – Tomás Apr 12 '13 at 15:16
  • @phpNoOb So what should i do in that line? Shall i give more space or shall give no space before php opne tag ` – Dan Apr 12 '13 at 15:20
  • @BurlsWillis no space, remove al. Updated my original answer with an explanation. – JackPoint Apr 12 '13 at 15:21
  • @BurlsWillis Also don't for get to check models/mainmenumodel.php and remove the wihtespace/newline there. – JackPoint Apr 12 '13 at 15:23
  • 1
    yes Its a Whitespace error before – Pratik Butani May 27 '13 at 11:18
  • 1
    For my issue, I had a php cron task that hit that controller every 5 minutes to run a function. That php cron file caused the session headers already sent issue. I had to move my session_start in that controller into a function that was NOT called by the cron php task. That fixed it. – Robot70 May 10 '16 at 16:03
  • @Robot70 Same issue on me, but I don't have `session_start()` on my controller, it is in `system/libraries/Session/Session.php`, and what error I get is `ERROR - 2020-03-02 15:24:02 --> Severity: Warning --> ini_set(): Headers already sent. You cannot change the session module's ini settings at this time` and more ... Do you have any solution? – highjump Mar 03 '20 at 11:17
  • highjump, i would read Jesse's comment on https://stackoverflow.com/questions/32814895/message-ini-set-a-session-is-active-you-cannot-change-the-session-modules – Robot70 Mar 03 '20 at 15:08