What is the better solution for check if is logged in |
What is the better solution for check if is logged in ?
app/Controllers/Back/DashbardController.php PHP Code: <?php namespace App\Controllers\Back; app/Controllers/Back/BackController.php ( Method 1 ) PHP Code: <?php namespace App\Controllers\Back; app/Libraries/AuthLibrary.php PHP Code: <?php namespace App\Libraries; app/Config/Services.php PHP Code: <?php namespace Config; app/Filters/LoginFilter.php PHP Code: <?php namespace App\Filters; app/Config/Filters.php ( Method 2 ) PHP Code: <?php namespace Config;
I'm a fan of filters for authentication (and really any route "filtering"). Note that you can return a RedirectResponse from Filter::before() to let the framework handle the redirect for you - much easier to testing and clean up and logging then using `header()` + `exit()`
|
Welcome Guest, Not a member yet? Register Sign In |