开发者

Write a few things to a session in cakephp

I am learning Session function in CakePhp, and see some examples like this on cakePHP

cookBook web site:

For example: 
write($mysession1, 'testing')

I am not sure if a session can only hold up a particular thing in it.

Is it p开发者_高级运维ossible to write an array to a session like:

mysession[0] = 'Testing0';
mysession[1] = 'Testing1';
mysession[2] = 'Testing2';


Yes, you can write an array to the session

$array = array('MyKey'=>'MyVal');
$this->Session->write('MySessionKey',$array);

Would write the array into the session. Alternatively you can build your array in the session.

$this->Session->write('My.Session.Key', $var);

This would essentially be, $_SESSION['My']['Session']['Key']

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜