CodeIgniter Forums
Error with session - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Error with session (/thread-25609.html)



Error with session - El Forum - 12-17-2009

[eluser]Unknown[/eluser]
In the name of Allah


i have probem with session

A PHP Error was encountered
Severity: Notice

Message: Undefined property: MhClass::$session

Filename: libraries/MhClass.php

Line Number: 19


Fatal error: Call to a member function userdata() on a non-object in C:\AppServ\www\code\system\application\libraries\MhClass.php on line 19


C:\AppServ\www\code\system\application\models\MHModel.php

##################################################################
<?php

class MHModel extends Model
{
function __construct()
{
parent::Model();
}
function SetIs()
{
return $this->db->get(“setting”);

}
}
?>





#################################################################









C:\AppServ\www\code\system\application\libraries\MhClass.php


############################################
<?php

class MhClass extends Controller
{
protected $data=array();
function __construct()
{
parent::Controller();
$this->load->model(“MHModel”);
$this->data[‘MH_Style’]=$this->Style();
$this->session->userdata(‘M’);
}
function Style()
{
return “templtes/main/”;
}

function Lang_dir()
{
return “site_lang/arabic/”;
}
function Data()
{
return $this->data;
}
}

?>
###############################################

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$



C:\AppServ\www\code\system\application\controllers\helal.php

######################################################

<?php

class helal extends Controller {

function __construct()
{
parent::Controller();
$this->load->library(“MhClass”);
$this->style =$this->MhClass->Style();
$this->lang_dir =$this->MhClass->Lang_dir();
$this->data =$this->MhClass->Data();
$this->data[‘SETTING’] =$this->MHModel->SetIs();
$this->lang->load(“index”,$this->lang_dir);
}

function index()
{
$this->load->view(‘welcome_message’);
$row=$this->MHModel->SetIs();
print_r($row->result_array());
}
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */
?>

#####################################################

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


C:\AppServ\www\code\system\application\controllers\helal.php


####################################################

<?php

class helal extends Controller {

function __construct()
{
parent::Controller();
$this->load->library(“MhClass”);
$this->style =$this->MhClass->Style();
$this->lang_dir =$this->MhClass->Lang_dir();
$this->data =$this->MhClass->Data();
$this->data[‘SETTING’] =$this->MHModel->SetIs();
$this->lang->load(“index”,$this->lang_dir);
}

function index()
{
$this->load->view(‘welcome_message’);
$row=$this->MHModel->SetIs();
print_r($row->result_array());
}
}

/* End of file welcome.php */
/* Location: ./system/application/controllers/welcome.php */
?>



##########################################################

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

C:\AppServ\www\code\system\application\controllers\Home.php


####################################################

<?php
class home extends Controller
{
protected $style =false;
protected $data =array();
protected $lang_dir =false;
function __construct()
{
parent::Controller();

$this->load->library(“MhClass”,null,‘MhClass’);
$this->load->model(“MHModel”);
$this->style =$this->MhClass->Style();
$this->lang_dir =$this->MhClass->Lang_dir();
$this->data =$this->MhClass->Data();

$this->data[‘SETTING’] =$this->MHModel->Get_St();
$this->lang->load(“index”,$this->lang_dir);
$this->session->set_userdata(array(“M”=>“MOHAMED”));

}
function index()
{

$this->data[‘pege_title’]=“MO “;
$this->data[‘pege_keys’]=“F “;
$this->data[‘pege_desc’]=” d”;
$this->load->view($this->style.“homepage.htm”,$this->data);

}
}
?>

#############################################################


&& when i open

http://localhost//code/system/application/controllers/Home.php

i got error



Fatal error: Class ‘Controller’ not found in C:\AppServ\www\code\system\application\controllers\Home.php on line 11



and other file

http://localhost//code/system/application/controllers/helal.php

its same


Fatal error: Class ‘Controller’ not found in C:\AppServ\www\code\system\application\controllers\helal.php on line 3

can i fine solution


Error with session - El Forum - 12-19-2009

[eluser]Peng Kong[/eluser]
1) Erm... for "MhClass.php" I don't think you can extend controller in your library folder.
Your controllers have to be in your controller folder!

2) Message: Undefined property: MhClass::$session
Filename: libraries/MhClass.php
Line Number: 19

You getting that because of (1) else check if you autoload ("core\application\config\autoload.php")
$autoload['libraries'] = array('database');