[eluser]zztemp[/eluser]
so i have my model where i make a select and if all's good, userdata() gets set.
Code:
$data = array(
'is_logged_in' => true,
'gebruiker' => $row['gebruikers_naam']
);
$this->session->set_userdata($data);
i wrote a function to check if your logged in or not:
Code:
public function is_logged_in(){
$is_logged_in = $this->session->userdata('is_logged_in');
if(!isset($is_logged_in) || $is_logged_in != true)
{
$data['title'] = "Intruder !!";
$data['views'] = array("v_message");
$data['message'] = "No acces mate";
$this->load->view('v_template',$data);
}else{
$data = "";
}
return $data;
}
Now in my contruct i do this:
Code:
public function __construct() {
parent::__construct();
}
now lets say i call a funtion:
Code:
public function plaatsbestelling()
{
$data['title'] = "De bestelling plaaten";
$data['views'] = array("v_bestelboninvullen");
$data['locaties'] = $this->maakLocatielijst();
$data['leveringsmethodes'] = $this->maakLeveringsmethodelijst();
$this->load->view('v_template',$data);
}
I would say that if i'm not logged in, he should take me to the view v_message and say "hold on my friend, you have no access or are not logged in". And is does that, but, it also loads the view given in plaatsbestelling();.
So how can i say, if you are not logged in, go to v_message and stop right there.
I tried the die(); function, but that just returns a blank page.
I kinda solved this by doing an if in my function:
Code:
public function plaatsbestelling()
{
if(!$this->is_logged_in()){
}
}
but i'm thinking common there must be a neater way to do this?