I have already read like half a dozen similar questions here, and already double checked that there are no white spaces before <?php or after ?> in my library.
Ok note that I get this error RANDOMLY. When I am on the page and press CTRL+R (refresh) multiple times, for like 2 or 3 consecutive tries, the error message is not there, and then the error message comes and stays for a few more tries..
the exact error message I am getting is
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</p>
<p>Message:  Cannot modify header information - headers already sent by (output started at A:\work\fast\semi 6\software engineering\project\project2\main\repo\main_proj\application\config\admin_template.php:2)</p>
<p>Filename: libraries/Session.php</p>
<p>Line Number: 672</p>
So obviously the culprit seems to be the admin_template.php library file..
my controller function that calls the library:
 public function view_items(){
    $this->session->set_userdata('f');
    $table="F";
    $this->admin_template->display_direct($table,'');
    }
I am copying the file here
note that <?php  is at line 1
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Admin_template{
    private
    $selected_item=-1,
    $menu=
        array(
        'Items'=>
            array(
              'Add Item'=>'admin/items/add_item',
              'View Items'=>'admin/items/view_items',
            ),
        'Administration'=>
            array(
                'View Admins'=>'admin/administration/view_admins',
                'View Representatives'=>'admin/administration/view_representative'
            )
        );
    public function __construct(){
    foreach($this->menu as $key=>$items){
        $this->menu[$key]['size']=sizeof($items);
    }
    $this->ci=&get_instance();
    }
    public function display_direct($view){
    $admin_template_data=array();
    $admin_template_data['content']=$view;
    $admin_template_data['heading']="heading";
    $admin_template_data['menu']=$this->menu;
    $admin_template_data['selected_item']=1;//$this->get_selected_item();
    return $this->ci->load->view('admin/main_template',$admin_template_data);
    }
}
