How to define and retrieve cookie value as array in CakePHP?
How to define and retrieve cookie value as array in Cak开发者_运维技巧ePHP?
You don't need to do anything special as Cake's CookieComponent handle's arrays seamlessly.
In your controller, make sure you've included the CookieComponent:
var $components = array('Cookie');
In your action, to write an array:
$this->Cookie->write('test', array('value1', 'value2'));
And then to read it back:
$test = $this->Cookie->read('test'); // $test will be an array
精彩评论