![]() |
CI 4 simple session auth system problem - 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: CI 4 simple session auth system problem (/showthread.php?tid=74736) |
CI 4 simple session auth system problem - adelbak - 10-30-2019 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 RE: CI 4 simple session auth system problem - dave friend - 10-31-2019 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() |