Welcome Guest, Not a member yet? Register   Sign In
Development of a own library
#1

[eluser]mb2007[/eluser]
Hello,

I want to develop a own library and have some trouble. I put my library in the folder /aplication/libraries and I add my library to the autoload array. But when I call my library in a controller I get a Warning headers already sent. Why?

My Library:
Code:
class mbauthentification
{

    function mbauthentification()
    {
        log_message('debug', "Authentification Class Initialized");
        
        $this->CI=& get_instance();
        $this->CI->load->library('session');
        $this->CI->load->helper('form');
        $this->CI->load->helper('url');
    }

    function login()
    {
        $email = $_POST['email'];
        $this->CI->session->set_userdata('email', $email);
        return true;
    }
}

The Controller:
Code:
class User extends Controller {

     function User()
     {
         parent::Controller();
     }

     function login()
     {
        if($this->mbauthentification->login())
        {
            echo "TEST";
        }
     }
}
#2

[eluser]Michael Wales[/eluser]
Is there any white-space prior to your opening/closing PHP tags in the files you developed? That's usually the culprit.
#3

[eluser]mb2007[/eluser]
No there are no white-spaces. It's just:
Code:
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
...
?>

What's about the get_instance() problem with PHP 4. Could that be the problem?
#4

[eluser]mb2007[/eluser]
Ok. The problem is to add something to the session cookie:
Code:
$this->CI->session->set_userdata('email', $email);

I solved it, to add it not to the cookie, but to the database table ci_session.
#5

[eluser]Doosje[/eluser]
You probably had already some sort of output .. before you'd set the cookie.




Theme © iAndrew 2016 - Forum software by © MyBB