CodeIgniter Forums

Full Version: Something wrong with Session library in CI 2.1.3
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]GabrielGem[/eluser]
Greetings dear CI commumity ! I'm new here and have a question. I have a problem with session library.

First of all, I create new library with that easy code:

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Auth{

function Auth()
{
$CI =& get_instance();
$CI->load->database();
$CI->load->library('session');
}
}

Then I write 'auth' variable to autoload, then open my index page and get this warnings:


Code:
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at F:\web\domains\devtools\application\libraries\auth.php:1)

Filename: libraries/Session.php

Line Number: 416
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at F:\web\domains\devtools\application\libraries\auth.php:1)

Filename: libraries/Session.php

Line Number: 675

But... If I put this library in the project based on CI 2.1.2 this library initialized perfect! w/o any errors and warnings. My Auth library not working on 2.1.3 Sad

Please help.

El Forum

[eluser]InsiteFX[/eluser]
Maybe you should use PHP5 Constructor's.

Code:
class Auth {

    private $CI;

    public function __construct()
    {
        $this->CI =& get_instance();
        $this->CI->load->database();
        $this->CI->load->library('session');
    }
}

Also if your going to use the session library you should autoload it.

El Forum

[eluser]coolfactor[/eluser]
Something is sending output prior to the Session library is being invoked. Make sure you don't have *any* whitespace outside of <?php and ?> tags that should not be there.

El Forum

[eluser]GabrielGem[/eluser]
Very glad to see you replies, thanks.! I'll check your recomendations

El Forum

[eluser]GabrielGem[/eluser]
Thanks, coolfactor! I'm so stupid )) there is a whitespace in the file. I convert file to UTF-8 without BOM and works fine for now without any warnings! It's so easy.
Many thanks!