[Catalyst] Make Catalyst NOT reset a cookie on a per action basis

Steve Kleiman steve at prodhub.com
Tue Aug 18 02:21:42 GMT 2009


Thanks for getting back again.

Weird. I didn't dig in too deep to figure why this is, but it is.

This was what was suggested but didn't work:
> $c->res->cookies({})

However this did:
> $c->res->headers->remove_header('Set-Cookie')


Thank you, Tomas.

-steve


On Aug 17, 2009, at 5:50 PM, Tomas Doran wrote:

>
> On 18 Aug 2009, at 01:19, Steve Kleiman wrote:
>
>> Thanks for taking a look. I thought I had it isolated but seems  
>> not. Tried what you suggested below but the instigator of the  
>> cookie happens at a different juncture.
>>
>> The instigator for a 'Catalyst::Plugin::Session' cookie being set  
>> is 'Session::prepare_action'. The method calls 'sessionid' which  
>> ultimately invokes the resetting of the cookie.
>
> Right.. But you then clear the cookie at the end of the hit, problem  
> solved?
>>
>> So a more refined question would be, is there a way to wrap only  
>> 'Session::prepare_action' whilst not wrapping all the other  
>> 'prepare_action' methods? I've tried the following but have had no  
>> luck:
>>> before 'prepare_action' => sub { ... }
>>> before 'Session::prepare_action' => sub { ... }
>>> before 'Catalyst::Plugin::Session::prepare_action' => sub { ... }
>>
>> Thanks for the help....
>
>
> Sure - Class::MOP::Class->initialize('Catalyst::Plugin::Session')- 
> >add_before_modifier iirc. Also - when you say 'wrap' - a before  
> modifier won't wrap a method - the method _always_ runs.
>
> Also, monkeypatching like this is a bad idea, as it has global  
> effect (your entire perl interpreter).
>
> Why doesn't the initial solution solve your problem, by clearing the  
> troublesome cookie (so the browser never sees it) at the end of the  
> hit.
>
> Cheers
> t0m




More information about the Catalyst mailing list