Session in CI 4 is not working accross the controller - 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: Session in CI 4 is not working accross the controller (/showthread.php?tid=77314) |
Session in CI 4 is not working accross the controller - samiul1978 - 08-15-2020 Home.php PHP Code: <?php namespace App\Controllers; TestSession.php PHP Code: <?php namespace App\Controllers; RE: Session in CI 4 is not working accross the controller - InsiteFX - 08-15-2020 I load it in the BaseController. And access it like this using the session helper: PHP Code: // Get session value using session helper RE: Session in CI 4 is not working accross the controller - Avega Soft - 08-15-2020 (08-15-2020, 10:37 AM)InsiteFX Wrote: I load it in the BaseController.Please, show all code your BaseController . Thank you in advance for your answer RE: Session in CI 4 is not working accross the controller - InsiteFX - 08-16-2020 Here you go, just remove the helpers and put your own in. You will always have access to $this->session as long as your controllers extend the BaseController. PHP Code: <?php RE: Session in CI 4 is not working accross the controller - Avega Soft - 08-17-2020 (08-16-2020, 03:17 AM)InsiteFX Wrote: Here you go, just remove the helpers and put your own in.Thanks! RE: Session in CI 4 is not working accross the controller - groovebird - 07-15-2022 (08-16-2020, 03:17 AM)InsiteFX Wrote: Here you go, just remove the helpers and put your own in. This question is old, but if you want access to the session in the constructor, then it is not working. The initController function is called after the constructor is called. RE: Session in CI 4 is not working accross the controller - Vishwas Gagrani - 08-01-2022 I encountered this problem recently. For me the reason was using hard-coded url: https://www.abcd.com. While the browser url was without “www” ie. https://abcd.com. So instead of hard coded url, i used base_url( ) to generate the base-url automatically. And that solved the session problem, and it is now working in all functions. |