How can I access request object and session data in my Component in cakephp 4.0?
I've got the following error Call to a member function getSession() on null after upgrade in the following code
$session = $this->request->getSession();
in my component.
To access Controller from within a component one should use
$this->getController()
(https://book.cakephp.org/4/en/controllers/components.html#accessing-a-component-s-controller).To access session you can use
$session=$this->getController()->getRequest()->getSession()
.