“src/Controller/Component” in this folder I’m created a “CustomComponent.php”.
How can i access Session in Component?
Got this error “Call to undefined method App\Controller\Component\CustomComponent::getRequest()”,
when try to “echo $this->getRequest()->getSession()->read(‘key’);”
pj($this->getController()->getRequest());
got this error
Call to a member function getController() on null
Component code
<?php
namespace App\Controller\Component;
use Cake\Controller\Component;
use Cake\Mailer\Email;
use Cake\Filesystem\Folder;
use Cake\Filesystem\File;
use Cake\ORM\TableRegistry;
use Cake\Http\ServerRequest;
class CustomComponent extends Component {
function __construct($prompt = null) {
}
public function sessRead() {
pj($this->getController()->getRequest());
exit;
}
}