Re: Cookie With Multi Dimensional Array Cannot Be Read (Sometimes) Is This A Bug?

2007-11-12 Thread Baz
Sorry, didn't know cookies were plain text. So serialization *should* work always, but it doesn't if you set the encryption option to *off*. I'm just sharing information trying to save others the hours I've spent with this problem. -- Baz L Web Development 2.0: Web Design, CakePHP, Javascript http

Re: Cookie With Multi Dimensional Array Cannot Be Read (Sometimes) Is This A Bug?

2007-11-12 Thread Ivolution
I agree with Grant Cox.. You can't just write any variable to a cookie. With plaintext strings this works, but when you have complex datatypes like multidimensional arrays, you have to convert it somehow to a plaintext string. This is exactly where the serialize() function kicks in: the only thing

Re: Cookie With Multi Dimensional Array Cannot Be Read (Sometimes) Is This A Bug?

2007-11-11 Thread Grant Cox
The reason it works in the first controller is because it is not reading from the cookie itself - it also saves the data to a local variable and it is reading back from that. Because there is no automatic serialization going on, only strings are written to the cookie - so a complex data type will

Re: Cookie With Multi Dimensional Array Cannot Be Read (Sometimes) Is This A Bug?

2007-11-11 Thread Baz
Thanks for the response, but here's a few FYIs. - What I posted before works fine with Sessions. That's actually how I determined the problem. I was building a "remember me" for a login. And I thought I could just dump the session variable in a cookie and retrieve later. So maybe if a

Re: Cookie With Multi Dimensional Array Cannot Be Read (Sometimes) Is This A Bug?

2007-11-11 Thread Ivolution
*Probably* the following will work: before writing your array to the cookie: $arr = serialize($arr); after reading it from your cookie (when $cookval is the value you read from your cookie): $arr = @unserialize($cookval); This way you should have your whole array back. Note however that I didn

Cookie With Multi Dimensional Array Cannot Be Read (Sometimes) Is This A Bug?

2007-11-11 Thread Baz
*Sigh*, So I've been pulling out my hair for a while until I figured, this thing just doesn't work the way it should. Here's my scenario very simplified with test data: Controller1: $arr['name']['1'] = '21'; $arr['name']['2'] = '21'; $arr['name1']['1'] = '21'; $this->Cookie->write('zilla', $arr