Welcome Guest, Not a member yet? Register   Sign In
Hook from redirect to page
#1

Hello,

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(); 
                
show_error(406); 
            }else if (
$this->perms[$this->CI->session->userdata('rolid')][$class][$method]) { 
                if(!
$this->CI->session->userdata('paid')){ 
                    
redirect('admin/index','location');                 
                }                         
                return 
true

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

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


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.
Reply
#2

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.
Reply
#3

I Use CI 3, the massaje is:

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

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.
Reply
#5

Thank jreklund, I resolve problem.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB