Welcome Guest, Not a member yet? Register   Sign In
What is the recommended method of having sessions always on

Hi All,

As per the title, I've been looking at filters and events. In CI3 I just autoloaded sessions.

I want sessions up and running as soon as possible to make decisions on their values.

(This post was last modified: 10-12-2021, 07:09 AM by manager.)

Hi. You can initialize it in a BaseController and other controllers will extend it.
PHP Code:
$protected $session;

public function 
initController(RequestInterface $requestResponseInterface $responseLoggerInterface $logger)
        // Do Not Edit This Line

        $this->session = \Config\Services::session();

Than you can access it like $this->session from ALL controllers extended from Base.

Theme © iAndrew 2016 - Forum software by © MyBB