Welcome Guest, Not a member yet? Register   Sign In
Accessin session
#1

[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?
#2

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




Theme © iAndrew 2016 - Forum software by © MyBB