CodeIgniter Forums

Full Version: Accessin session
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
i got this error when access session

A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Loader::$session

Filename: views/search.php

Line Number: 35

Fatal error: Call to a member function userdata() on a non-object in C:\htdocs\CodeIgniter\system\application\views\search.php on line 35

this is the function in the login model
function checkLogin($username,$password){
$sql = "SELECT * FROM userinfo WHERE Username=? AND Password=?";
$query = $this->db->query($sql, array($username, $password));
if ($query->num_rows() == 1){

$row = $query->row();
$this->load->library('session');
$this->session->set_userdata('SessionUsername',$row->UserName);
$query->free_result();
$data['searchResult']= "";
$this->load->view('search',$data);

}
else{
$data['title'] = "Welcome to Collaborative Search";
$data['LoginType']="Login";
$data['failedType'] =4;
$this->load->view('loginview',$data);

}


}

i access the session by echo $this->session->userdata('SessionUsername'); in the search view file.

but i got the aboved mention error.

May i know how to solve?

El Forum

[eluser]GSV Sleeper Service[/eluser]
sounds like the session library is not being loaded. can you post line 35 of views/search.php?