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

Tomas Doran bobtfish at bobtfish.net
Tue Aug 18 00:50:17 GMT 2009

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  
> 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.


More information about the Catalyst mailing list