CodeIgniter Forums
Hook from redirect to page - Printable Version

+- CodeIgniter Forums (
+-- Forum: Using CodeIgniter (
+--- Forum: General Help (
+--- Thread: Hook from redirect to page (/showthread.php?tid=71532)

Hook from redirect to page - Wilmer - 08-25-2018


I need that when I load the system I verify a session "paid" if it exists and its value is greater than zero, so that the system continues normal, but if the system does not exist or is zero, then it automatically redirects a controller and a method to force the user to assign the session "paid".

 if ($this->CI->session->userdata('rolid')) { 
// echo $this->perms[$this->role_field][$class][$method]; exit(); 
if (!isset($this->perms[$this->CI->session->userdata('rolid')][$class][$method])){ 
// echo 'entre aqui'; exit(); 
            }else if (
$this->perms[$this->CI->session->userdata('rolid')][$class][$method]) { 

// redirect('welcome','location'); 
} else { 

        } else { 
// print_r($class).'<br>'.print_r($method); exit(); 
if(strtolower($class) == 'login' || strtolower($class) == 'admin'){ 

That code is part of an ACL in a hook post_controller_construtor where I try to redirect with redirect('admin/index', 'location'); but the browser gets me an error, of "too many requests".

Any help or advice would be appreciated.

RE: Hook from redirect to page - jreklund - 08-25-2018

Make a search in your project after the phrase "too many requests" as that's not something that is included by default in CI 3 (but in CI 4). Maybe it's in any of your included libraries. If not, it's your webhost that are giving you these typ of problem.

RE: Hook from redirect to page - Wilmer - 08-25-2018

I Use CI 3, the massaje is:

Esta página no funciona
localhost te redireccionó demasiadas veces.
Intenta borrar tus cookies.

RE: Hook from redirect to page - jreklund - 08-26-2018

That's a completely different message. For some reason you are creating a infinite loop of redirects. You need to start removing some code and see where it always returns true (or false) and keeps redirecting the user.
If the problem gets solved by just removing "redirect('admin/index','location');" you are always returning false on "$this->CI->session->userdata('paid')" and you should stop checking for it in admin/index.

RE: Hook from redirect to page - Wilmer - 08-27-2018

Thank jreklund, I resolve problem.