Reputation: 841
I want to load session in ci, Here is my class and its constructor
class User extends CI_Controller {
function __construct() {
$data = array('name'=>'Hussain','password'=>'rahimi');
$this->load->library('session');
} // __construct()
}
It gives me the following error:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: User::$load
Filename: controllers/user.php
Line Number: 5
Could someone help me? thanks in advance.
Upvotes: 0
Views: 836
Reputation: 9442
You are missing the parent`s constructor thus you are overriding it, replace your code with:
class User extends CI_Controller {
function __construct() {
parent::__construct(); //HERE
$data = array('name'=>'Hussain','password'=>'rahimi');
$this->load->library('session');
}
}
Check the documentation: http://ellislab.com/codeigniter/user-guide/general/controllers.html
Upvotes: 1