[eluser]Phil Sturgeon[/eluser]
Right k, STOP right there.
That is one nasty way of user authentication. To answer your question, try the code:
Code:
if(!$this->session->userdata('logged_in')) {
$this->load->view('login');
exit(); // <-- Add that
}
But this code is not the way to go. Instead of using this code in _init use it in a hook. In /config/hooks.php add:
Code:
$hook['post_controller_constructor'][] = array(
'function' => 'grantAccess',
'filename' => 'grantAccess.php',
'filepath' => 'hooks',
);
Enable hooks in /config/config.php
Make a file in /hooks/ called grantAccess.php and make a function the same name.
In that function, put your authorisation code. That will make it load for all controllers!
You could put in an array or a few if's for pages you dont want blocked. For example:
Code:
$class = $CI->uri->router->class;
$method = $CI->uri->router->method;
if(in_array($class, $public_classes)) return;
if(in_array($method, $public_methods)) return;
Something like that.