Welcome Guest, Not a member yet? Register   Sign In
Problem with fetch_class() and redirect()
#1

Hi everybody,
I've a little problem with fetch_class and redirect.
I'm using this two method in this way, in my core controller Admin_Controller:
PHP Code:
if (!$this->router->fetch_class() == 'login' && !$this->ion_auth->is_admin()) {
 
           $this->session->set_flashdata('message''You must be an admin to view this page');
 
           redirect('admin/login');
 
       
I'm trying to check if the user is an admin, else he will be redirected to the login page, but the login page share the same controller that extend MY_Controller. (Admin_Controller) So this code without the fetch_class() control would cause an infinite loop. But if i omit the fetch_class(), the redirect() work. I've tried everything but couldn't find out why this is happening :C
(Anyway, sorry for my poor english ><)
Reply
#2

try this

PHP Code:
if ($this->router->fetch_class() != 'login' && !$this->ion_auth->is_admin()) 

Reply
#3

Works perfectly, thanks! Big Grin
Reply




Theme © iAndrew 2016 - Forum software by © MyBB