I have a controller
<?php
class Onetimescan extends CI_Controller{
public function index() {
#LOAD MODEL
$this->load->model('scanmodel');
$this->scanmodel->loadurlbasedonsessid($this->session->userdata('session_id'));
}
}
?>
and a model:
<?php
class Scanmodel extends CI_Model{
function __construct(){
// Call the Model constructor
parent::__construct();
}
function loadurlbasedonsessid($sid){
$sid = $this->session->userdata('session_id');
$this->db->select('tld');
$this->db->where('session_id', $sid);
$q = $this->db->get('ClientDomain');
$r = $q->result_array();
echo($r[0]['tld']);
}
}
?>
I’m getting the following error:
Call to a member function userdata() on a non-object
I thought I was properly passing the session_id in between the controller and model, but this isnt the case? Can someone please help?
Thanks
It looks like the Session library isn’t loaded.
To load it on demand (usually in the controller):
or add it to your
application/config/autoload.php: