Welcome Guest, Not a member yet? Register   Sign In
Bool in session is turned into string
#1

[eluser]überfuzz[/eluser]
I did a login system, quite simple but its dandy. But looking through the code I found something puzzling.

In the function setting the session-value to state logged in.
Code:
$data = array(
    'username' => $this->input->post('username'),
    //etc...
    'logged_in' => TRUE //this would be the boolean.
);
$this->session->set_userdata($data);

In the my MY_Controller I only just realized that I was checking logged_in like this:
Code:
if($this->session->userdata('logged_in') != TRUE ) //not !==
{
    redirect('login');
}
!== didn't work so I trowed a
Code:
var_dump($this->session->userdata('logged_in')); //output string(1) "1"

Why is the bool turned into a string?

Edit, a glitch pointed out by bigtony plus != TRUE


Messages In This Thread
Bool in session is turned into string - by El Forum - 10-06-2009, 12:54 AM
Bool in session is turned into string - by El Forum - 10-06-2009, 01:39 AM
Bool in session is turned into string - by El Forum - 10-06-2009, 02:29 AM
Bool in session is turned into string - by El Forum - 10-06-2009, 02:32 AM
Bool in session is turned into string - by El Forum - 10-06-2009, 02:52 AM
Bool in session is turned into string - by El Forum - 10-06-2009, 02:55 AM
Bool in session is turned into string - by El Forum - 10-06-2009, 03:14 AM
Bool in session is turned into string - by El Forum - 10-06-2009, 03:39 AM
Bool in session is turned into string - by El Forum - 10-06-2009, 04:22 AM
Bool in session is turned into string - by El Forum - 10-06-2009, 08:28 AM
Bool in session is turned into string - by El Forum - 10-06-2009, 10:52 AM
Bool in session is turned into string - by El Forum - 10-06-2009, 11:01 AM
Bool in session is turned into string - by El Forum - 10-06-2009, 11:55 AM
Bool in session is turned into string - by El Forum - 10-06-2009, 04:36 PM
Bool in session is turned into string - by El Forum - 10-06-2009, 08:46 PM
Bool in session is turned into string - by El Forum - 10-07-2009, 12:39 AM
Bool in session is turned into string - by El Forum - 10-08-2009, 09:59 AM
Bool in session is turned into string - by El Forum - 10-08-2009, 11:45 AM
Bool in session is turned into string - by El Forum - 12-26-2009, 06:14 PM
Bool in session is turned into string - by El Forum - 03-29-2010, 03:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB