Welcome Guest, Not a member yet? Register   Sign In
Difficulties with autoload session
#1

(This post was last modified: 07-17-2021, 04:59 PM by Iosef.)

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?
Reply
#2

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 07-18-2021, 02:37 AM by Iosef.)

[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]
Reply




Theme © iAndrew 2016 - Forum software by © MyBB