checking session |
[eluser]runrun[/eluser]
Hi, I am checking session logged in to display user data. I do like this, when user loin successfully I set session Code: $data =array ('logged_in'=>'TRUE'); When I check I do like this Code: if($this->session->userdata(logged_in) != TRUE){access denied...} All good, everything works as expected. But isn't that I have to check like this ? Code: if($this->session->userdata(logged_in) != 'TRUE'){access denied...}
[eluser]pistolPete[/eluser]
If you check using !=, the string 'TRUE' will be casted to a boolean value (which will result in TRUE). If you want to avoid this, you'd have to use !==. Have a look at language.types.boolean.php.
[eluser]jedd[/eluser]
I get around this problem by just doing this: Code: $this->session->set_userdata('login', $login_name); My logout function unsets that session variable. Tests are then quite simple: Code: if ($this->session->userdata('login') |
Welcome Guest, Not a member yet? Register Sign In |