Google News
logo
CakePHP - Interview Questions
How to create Cookie in CakePHP?
CakePHP offers an easy and secure way to manage cookies. In CakePHP, CookieComponent class is used to manage cookies. It sets the cookie path, expiration, domain, key, encryption, and many more. To configure a cookie, you need to use the config() method.
$this->Cookie->config([   
   'expires' => '+5 days',   
   'httpOnly' => true   
]);  ​

 

The above function is used to create and configure the cookie. After configuring the cookie, you can read, write, delete, and check cookie data with various methods provided by the CookieComponent class.
Advertisement