Hussain Rahimi
Hussain Rahimi

Reputation: 841

Undefined property: User::$load in ci

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

Answers (1)

ka_lin
ka_lin

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

Related Questions