Panos Mavromytis
Panos Mavromytis

Reputation: 51

Codeigniter - Cannot modify header information - headers already sent by

A PHP Error was encountered
Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/aphotel/public_html/application/config/config.php:1)

Filename: libraries/Session.php

Line Number: 366
#

Weird part of it, there is no session.php file in libraries folder

Upvotes: 5

Views: 34191

Answers (8)

Anil Gupta
Anil Gupta

Reputation: 1641

In PHP Use " ob_start(); " at first line and in CI controller constructor at first line " ob_start(); " //output buffer

Upvotes: 8

fcfeitosa
fcfeitosa

Reputation: 63

Just load session library first.

$autoload['libraries'] = array('session', 'encrypt', 'database',...

Upvotes: 2

user1080381
user1080381

Reputation: 1786

I changed encoding to 'UTF-8 without BOM' for all php files in model, controller and helper folders and that helped.

Upvotes: 3

Donovan
Donovan

Reputation: 926

There is space before the <?php tag in the below file. I have seen this issue multiple times.

(output started at /home/aphotel/public_html/application/config/config.php:1)

Upvotes: 4

Ashraf Kaabi
Ashraf Kaabi

Reputation: 131

I had this problem before and it was caused by output_buffering was Off.

Edit your php.ini and search for output_buffering and make it looks like this

output_buffering = On

Upvotes: 9

Neil Dhakal
Neil Dhakal

Reputation: 363

There seems to be whitespace before the php open tag

Upvotes: 4

mohsin139
mohsin139

Reputation: 1027

Make sure you do not have any white space characters before the opening php tag in your controller class.

Upvotes: 4

vimal dhaduk
vimal dhaduk

Reputation: 41

Remove print_r(); in controller, model or session. There are problem or warning when website upload in host server not warning in localhost

Upvotes: 4

Related Questions