![]() |
My Library cannot see session - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11) +--- Thread: My Library cannot see session (/showthread.php?tid=92873) |
My Library cannot see session - PaulC - 05-08-2025 Hi Team, (having resolved helper issue) the debugging show one of my libraries cannot see the session. I have loaded the library (Template) and the session in the BaseController ie PHP Code: <?php I appreciate the libs do not extend BaseController, but I was hoping $this->template and $this->session would be available to everything. I'm sorry but I appear to be in a morasse of object inheritance and am not sure what to do to fix this? The error thrown is: Undefined property: App\Libraries\Template::$session The code snippet from my Template lib is; PHP Code: public function render($name, $admin = false) RE: My Library cannot see session - michalsn - 05-08-2025 You must either pass a session in your library's constructor or use a helper. PHP Code: $this->template = new \App\Libraries\Template($this->session); or simply: PHP Code: public function render($name, $admin = false) RE: My Library cannot see session - InsiteFX - 05-08-2025 You can also use the session helper. PHP Code: public function render($name, $admin = false) |