Welcome Guest, Not a member yet? Register   Sign In
Cannot modify header information - headers already sent by (output started at C:wampwwwappcoreMY_Controller.php:1)


Thanks to this framework I've been able to learn some PHP and OOP after three decades of linear COBOL programming. Thanks for that.

I looked for an answer to this but to no avail.
I'm running a WAMP server, using PHP 5.3.10 and CI 2.1.3

MY_Controller, in the error text, which lives in app\core\MY_Controller.php looks like this...

class MY_Controller extends CI_Controller
    function __construct()

        if (!$this->session->userdata('loggedin'))

I did this so that any page that requires being logged in will extend this controller instead of CI_Controller,
but the weirdest part is that I have not yet extended this controller anywhere ?!

The full text of the error is this...
Quote:A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at C:\wamp\www\app\core\MY_Controller.php:1)

Filename: libraries/Session.php

Line Number: 676

Considering that I have not overridden the session library, then I'm lead to believe that this must be pointing to sys\libraries\session.php.

Line 676 points directly to the setcookie statement...
Doesn't setting the cookie constitute output to the browser?
And once you do that, you can't then later send out browser content without getting this "severe" type error.
I commented this statement and the error went away. But then a cookie doesn't get set.
What's the ramifications of that? How do we solve this problem?

Have you saved this file (MY_Controller.php) with an invalid UTF-8 BOM, or with a new line before the "<?php"?

Try saving it as DOS encoding.

Theme © iAndrew 2016 - Forum software by © MyBB