[eluser]johnmchilton[/eluser]
My login function sets a session userdata variable called "logged_in". At the beginning of each other function, the value of that is checked. This was a terrible solution, because it meant that all of the function's code had to be in an else {} block:
Code:
function index() {
if(!$this->session->userdata('logged_in') {
$this->load->view('login');
} else {
//what this function is meant to do, ending with...
$this->load->view('main');
}
}
So I decided to move that to a private function, which I'm calling _init(). Here is the basic structure of how I
want it to work:
Code:
function _init($check=true) {
$data["header"] = "Welcome ...";
$data["title"] = "Site Title ...";
if($check) {
if(!$this->session->userdata('logged_in')) {
$this->load->view('login');
}
}
}
function index() {
$this->_init();
$this->load->view('main');
}
However, loading the login view doesn't stop execution. I don't know how to get the login part to stop the rest of its caller...does anyone know what I'm trying to say or how to help? Thanks!