[eluser]comyou[/eluser]
Hello all,
I current want to run a function to check if the logged in user is an admin everytime a new page is loaded.
My function is
Code:
function check_admin() {
$logged_in = $this->session->userdata('logged_in');
if ($logged_in == TRUE) {
$this->get_where_custom('username', 'admin');
foreach($query->result() as $row) {
if ($row->num_rows() == 0) {
$this->session->unset_userdata('is_admin');
$this->session->set_userdata('is_admin', FALSE);
} else {
$this->session->unset_userdata('is_admin');
$this->session->set_userdata('is_admin', TRUE);
}
}
}
}
However I'm not sure if this is working properly but I could always fix that once it loads on every page.
The function is found in my 'application/modules/secure/security.php'
I've tried putting it in a helper file (but being honest, I wasn't really sure what I was doing.
How would I load the function when every page loads?
Thanks in advanced.