This is my Users model
public function user_login($email, $password)
{
$this->load->library('session');
$this->db->where('email', $email);
$this->db->where('password', $password);
$query = $this->db->get('users');
if($query->num_rows() > 0) {
foreach($query->result() as $row) {
$data = array(
'id' => $row->id,
'username' => $row->username,
'email' => $row->email
);
$this->session->set_userdata($data);
}
return 1;
} else {
return false;
}
}
On my view i have a div to display the session username of the user
<div>
<?php echo $this->session->userdata('username'); ?>
</div>
It's does not appear What could be wrong?
When I print the contents of userdata() like this
<?php print_r($this->session->userdata()); ?>
I get the response
Array ( [__ci_last_regenerate] => 1502894606 )