[Catalyst] hostname

Carl Johnstone catalyst at fadetoblack.me.uk
Fri Jan 11 10:29:39 GMT 2008


> cookie_domain => the_host()
> in the MyApp config, but when I try to start the server it gives an error 
> telling that I can't use the method "req" because $c is undefined.

I'd be curious about why you wanted the cookie domain in the config anyway!

I presume you've got a bit of code like:

$c->response->cookies->{'foo'} = { domain => $c->config('cookie_domain') };

In which case why couldn't you just do

$c->response->cookies->{'foo'} = { domain => $c->req->hostname };

> But anyway, what I need is working because I can avoid setting a domain 
> name for the cookie.

Yeah exactly, setting the domain in the cookie to match the domain requested 
is pretty pointless anyway as that's what browsers do by default. About the 
only time you need to send a domain back is when you want to set a cookie 
across all subdomains or similar. Eg: { domain => '.example.com' }


Carl




More information about the Catalyst mailing list