CodeIgniter Forums
Problem with redirect-> to - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Problem with redirect-> to (/showthread.php?tid=76926)



Problem with redirect-> to - hugoafr - 07-03-2020

Hello,
sorry for my English,
I have a strange problem, redirection works fine when I call it from a method, but when I call it from a function it doesn't work.

Example:

PHP Code:
   //Example function to redirect
    public function _redirect_user(){
        return redirect()->to(site_url('proyecto/index'));
    }
    
    
//This does not work, it does not throw an error, it is just as if the process ended.
    public function my_method_a()    
    
{
        $this->_redirect_user();
    }
    
    
//This works fine.
    public function my_method_b()    
    
{
        return redirect()->to(site_url('proyecto/index'));
    



RE: Problem with redirect-> to - inumaru - 07-04-2020

Try to return in your my_method_a() function.

PHP Code:
return $this->_redirect_user(); 



RE: Problem with redirect-> to - hugoafr - 07-04-2020

(07-04-2020, 01:39 AM)inumaru Wrote: Try to return in your my_method_a() function.

PHP Code:
return $this->_redirect_user(); 

Funcionó de esa forma, muchas gracias amigo.

It worked that way, thank you very much friend.

Big Grin