[Catalyst] Setting cookie_domain

Bernhard Graf catalyst2 at augensalat.de
Tue Apr 17 09:40:37 GMT 2007

On Monday 16 April 2007 18:55, Bernhard Graf wrote:

The code I posted yesterday doesn't work. NEXT::finalize_cookies() has
to be called at the end.
Here is a fixed version, that also doesn't alter the cookie domain if
it's already set:

sub finalize_cookies {
    my $c = shift;

    my $sc = $c->response->cookies->{$c->config->{session}->{cookie_name}};

    if (defined($sc) and ref($sc) eq 'HASH') {
        $sc->{domain} ||= (/(\.[^\.]+\.[^\.]+)$/)[0] || $_ for $c->request->uri->host;

Bernhard Graf

More information about the Catalyst mailing list