开发者

How to define and retrieve cookie value as array in CakePHP?

开发者 https://www.devze.com 2023-03-04 08:42 出处:网络
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.

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
0

精彩评论

暂无评论...
验证码 换一张
取 消