I want to set the config for the cookie component but I am unsure where to add the code.
Do I set it in the AppController or the bootstrap?
public function initialize()
{
parent::initialize();
$this->loadComponent('Csrf');
$this->Cookie->config([
'httpOnly' => true
]);
}
According to http://book.cakephp.org/3.0/en/controllers/components.html#configuring-components
Assuming that you need to configure it globally, you should place the configurationcode into the
initialize()
of theAppController
.If you want to override the configuration at runtime, you can place the code into the
beforeFilter()
of a controller.