Example
$this->Cookie->write('name', 'Virat');
We can pass array of name, values pair to write multiple cookies.
Read Cookie
The
read()
method is used to read cookie. Following is the syntax of the read() method.
Cake\Controller\Component\CookieComponent::read(mixed $key = null)
The read() method will take one argument, the name of cookie variable ($key).
Example
echo $this->Cookie->read('name');
Check Cookie
The
check()
method is used to check whether a key/path exists and has a non-null value.
Following is the syntax of the
check()
method.
Cake\Controller\Component\CookieComponent::check($key)
24.
CakePHP — Cookie Management
CakePHP
81
Example
echo $this->Cookie-
>check(‘name’);
Do'stlaringiz bilan baham: |