CodeIgniter Forums
Difficulties with autoload 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: Difficulties with autoload session (/showthread.php?tid=79674)



Difficulties with autoload session - Iosef - 07-17-2021

In my base controller under the line parent::initController($request, $response, $logger); I added this other:

$session = \Config\Services:Confusedession($config)

However Im trying to use flash data in my login controller and Im getting the following error:
Call to a member function setFlashdata() on null

It looks that what I did was not enough to have session autoloaded in every controller. What am I missing?


RE: Difficulties with autoload session - InsiteFX - 07-17-2021

You can also use the session helper method.
PHP Code:
session()->setFlashdata('item''value'); 

BaseController:
PHP Code:
    if (session_status() == PHP_SESSION_NONE)
 
    {
 
    $this->session Services::session();
 
    



Try that.


RE: Difficulties with autoload session - Iosef - 07-17-2021

[quote pid="388644" dateline="1626581238"]
Thank you, was actually a silly mistake, I started the session in the default controller as $session; instead of $this->session;
[/quote]