Reputation: 657
I need to add in a sessione some variables that I obtain after I do login. This is my code in my model.php:
function login($username,$password)
{
$query = $this->db->query("SELECT * FROM user WHERE username='".$username."'");
$row = $query->row();
if (isset($row))
{
$this->session->set_userdata('logged','isLogged');
return 1;
}else{
return 0;
}
}
The proble is that when I check the value in the session (google chrome) I doesn't read the "logged" parameter. Anyone can help me?
Upvotes: 0
Views: 41
Reputation: 289
What you are looking at is the browser session storage. PHP/CodeIgniter lives on the server and therefore will not use this storage.
You will find your variable set in the PHP $_SESSION
superglobal. You can access it like so:
$_SESSION['logged'];
Alternatively, you can use the CodeIgniter magic getter method:
$this->session->logged;
You can find more info on CodeIgniter sessions here.
Hope this helps.
Upvotes: 2