tags:

views:

20

answers:

1

Hi all,

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 possible to write an array to a session like:

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

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']

DavidYell