I have read the Cakephp documentation but it doesn't working well. Here is my code,
$this->response = $this->response->withCookie('remember_me', [
'value' => 'yes',
'path' => '/',
'httpOnly' => true,
'secure' => false,
'expire' => strtotime('+1 year')
]);
$rememberMe = $this->request->getCookie('remember_me');
Please look at the documentation. You will find it in the following link:
https://book.cakephp.org/3.0/en/controllers/request-response.html#Cake\Http\Cookie\CookieCollection
To create a cookie
Now add the cookie in the cookie collection:
Now read cookie this way.
Hope you will find it's working.
Here should mention an important point: Cookie writing and reading must be two separate http request.