[eluser]San2k[/eluser]
Hi!
Didn't find an answer on forums (maybe i looked bad
)
I have a problem with checking if user is logged in. So i'am doing this:
Code:
class MyPROG extends Controller {
function MyPROG ()
{
parent::Controller();
$user_table = 'users';
$this->load->helper(array('form', 'url'));
if(!$this->session->userdata('logged_in')){
$this->load->view('header');
$this->load->view('login');
}
}
It checks correctly, but the problem is - that if user is NOT logged,
$this->load->view('header');
$this->load->view('login');
- this two view files will be loaded + my Index function will be loaded too.
Code:
function index()
{
$this->load->view('header');
$this->load->view('add_employer');
}
if i put exit; after $this->load->view('login'); in main function - nothing loads at all.
My main idea, why i did it that way - is that MyPROG runs before any function in controller(is that right?) - so its the best place to check login. so noone can access any functions bypassing login check.
Thanks.