How to define global SESSION in CakePHP’s AppController?

I am using CakePHP 3.3

My Controller:

class ConfigsController extends AppController
{

    public $session;

    public function initialize()
    {
        parent::initialize();
        $this->loadComponent('CheckAuthUserSession');

        $this->session = $this->request->session();
    }
}

I have this line below in every controller of my project

$this->session = $this->request->session();

Is there a way to define this in AppController’s initialize() and then I can access it by parent::session? Or anywhere else which makes it global.


Source: stackoverflow-php