CI 4 simple session auth system problem |
Firstly I'm sorry for my very*100 bad Engilsh
Please help to solve this problem, and thank you in advance. I am programming a site based on an simple session auth system, but I have had two problems . - Let's take a look at the files: BaseController.php Controller: PHP Code: <?php Auth.php Controller: PHP Code: <?php namespace App\Controllers; Problem 1: when i browse Auth (auth/index): Call to a member function has() on null Error...Even though I called and start session class/service from initController function in BaseController . - When the problem is solved in a ugly way by call session class/service inside loggedIn() function like this: PHP Code: protected function loggedIn() The second problem: the function does not redirect to /dashboard/index, even i'm sure a having a successful login and loggedIn = username not null or empty or false Help..Thanks
Remove the following line from BaseController. It is not needed because the session library does this for you.
PHP Code: $this->session->start(); That may be the reason $this->session is coming up null. Try this change for loggedIn() PHP Code: protected function loggedIn() Then you can remove public function notLoggedIn() |
Welcome Guest, Not a member yet? Register Sign In |