CodeIgniter Forums
Message: Cannot modify header information - headers already sent by (output started at etc. Filename: libraries/Session. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Message: Cannot modify header information - headers already sent by (output started at etc. Filename: libraries/Session. (/showthread.php?tid=46920)



Message: Cannot modify header information - headers already sent by (output started at etc. Filename: libraries/Session. - El Forum - 11-20-2011

[eluser]Unknown[/eluser]
CodeIgniter error: Message: Cannot modify header information - headers already sent by (output started at etc. Filename: libraries/Session.php SOLVED

Solution: Autoload the Session.php

Isolating the error that caused the error look at the code below:
These lines:
Code:
$this->load->library('table');   exit();
$this->load->library('session');

did not produce an error.

====================================
These lines

Code:
$this->load->library('table');
$this->load->library('session');exit();

or

Code:
$this->load->library('table');$this->load->library('session');exit();
result in the following error:

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /var/www/bmak.ca/cssmenu.php:20)

Filename: libraries/Session.php

Line Number: 672


The solution: was to autoload session ref: http://ellislab.com/codeigniter/user-guide/general/autoloader.html

made the change:
Code:
$autoload['libraries'] = array('session');
note: you don't need to have an array - I will likely autoload other classes.

The above ERROR no longer occurred.