Redirect on a Controller contruct - 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: Redirect on a Controller contruct (/showthread.php?tid=72439) |
Redirect on a Controller contruct - Perhood - 12-19-2018 Hi and sorry for my bad english, I have parent construct that check if the user is logged to let them see the page or redirect them to the login but since I updated to the alpha 3 it not works: The route I try to go without login: PHP Code: $routes->add('{locale}/app/', 'Dashboard::index', ['namespace' => 'App\Controllers\Appmudet']); The Dashboard Controller that extends from the Appcontroller: PHP Code: <?php namespace App\Controllers\Appmudet; The Appcontroller : PHP Code: <?php namespace App\Controllers\Appmudet; It shows me the var_dump and then the redirect dosen't seems to work because shows me the app view not the login. Both controlles are on the same folder: 'Controllers/Appmudet' RE: Redirect on a Controller contruct - bvrignaud - 12-19-2018 PHP Code: public function __construct() { I don't think your "return" in a constructor will be effective. Th only way I found, is to test "loggedIn" in each function. RE: Redirect on a Controller contruct - kilishan - 12-19-2018 Redirecting from constructors is no longer possible in CI4. Use Controller filters instead. |