Hi guys having a bit of a problem with setting userdata to true, maybe someone on here can help me out?
I am using codeigniter
here is my controller where I set the userdata and redirect forward to another controller "site" and call the function members_area
if($query) // if the users pass/user is right
{
$data = array(
'username' => $this->input->post('username'),
'is_logged_in' => true
);
$this->session->set_userdata($data);
redirect('site/members_area');
}
else{
$this->index();
}
Then this is my site controller:
function __construct(){
parent::__construct();
$this->is_logged_in();
}
function members_area()
{
$this->load->view('members_area');
}
function is_logged_in()
{
$is_logged_in = $this->session->userdata('is_logged_in');
if(!isset($is_logged_in) || $is_logged_in != true)
{
echo 'You don\'t have permission to access this page. <a href="../login">Login</a>';
die();
}
}
What do you guys reckon? Much appreciated!