Sunday, October 24, 2010

Re: Cookies--getting chocolate in my peanut butter (and vice versa)

Apologies--using 1.3.5

On Mon, Oct 25, 2010 at 1:28 AM, cricket <zijn.digital@gmail.com> wrote:
> On Mon, Oct 25, 2010 at 12:57 AM, cricket <zijn.digital@gmail.com> wrote:
>> I have two plugins, Comments and Poll. Both have a component, and each
>> of those components uses CookieComponent. They also both handle Cookie
>> settings in startup(). Unfortunately, it appears that they're sharing
>> the same component instance, as the 'poll' cookie is being re-named to
>> 'comments'.
>>
>> I've checked, and the original controller using the plugins does not
>> use Cookie directly. However, AppController does. But there doesn't
>> appear to be any issue there as I can see the default 'CAKEPHP' also.
>>
>> So, if each plugin can't have it's own separate cookie (much
>> preferred) it looks like I'll have to resort to using the default one
>> and using namespace/dot notation for the keys. But what if the app
>> itself doesn't use Cookie anywhere? Should each plugin component then
>> fall back to the name of the plugin?
>>
>
> Argh! So I commented out the parts where I assign a name to the
> cookie, going with CookieComponent's default 'CakeCookie'. My plugin
> components now use namespaces, 'Poll' and 'Comments'. eg.
>
> $this->Cookie->write('Poll.completed', serialize($this->_completed_polls));
>
> All fine, I can see 3 separate cookies (including Session's). However,
> this line:
>
> $this->_completed_polls = (array)
> unserialize($this->Cookie->read('Poll.completed'));
>
> gives me this grief:
>
> Notice (8): unserialize() [http://php.net/function.unserialize]: Error
> at offset 0 of 14 bytes
> [APP/plugins/poll/controllers/components/poll_handler.php, line 60]
>
> And $_completed_polls is empty. Same for the Comments plugin. I tried
> passing false to write() in case the encryption was somehow the issue.
> No cigar.
>
> Am I doing this wrong?
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: