[Catalyst] Setting cookie_domain

Fernan Aguero fernan at iib.unsam.edu.ar
Sun Apr 15 20:32:01 GMT 2007


+----[ Bernhard Graf <catalyst2 at augensalat.de> (15.Apr.2007 16:20):
|
| On Sunday 15 April 2007 19:32, Fernan Aguero wrote:
| > +----[ Bernhard Graf <catalyst2 at augensalat.de> (15.Apr.2007 08:23):
| > | Hi,
| > |
| > | I'm wondering how to set the cookie_domain of
| > | Catalyst::Plugin::Session::State::Cookie when you run a site under
| > | different domains.
| > |
| > | The manual only gives advice how to do this in the (static)
| > | configuration - and from looking at the source I get the impression
| > | that I either had to sub class and override more or less
| > | undocumented methods or otherwise had to patch.
| > |
| > | Or is there a (better) third way?
| >
| > +----]
| >
| > config your app using YAML. In your lib/app.pm file add
| > 'ConfigLoader' to the list of plugins.
| >
| > The good thing about this setup is tat you can have a main
| > config file and _local overrides for similar but not
| > identical installations.
| 
| Thank you, but this doesn't help. Because I have only one application 
| that can be accessed under different domains (same 2nd-level domain 
| with TLDs .de, .at and .ch im my case).
 
Oh, I see. -- BTW I'm in geneva now :)

| The documentation for Catalyst::Plugin::Session::State::Cookie claims 
| that the default value for cookie_domain is the current host, which is 
| not true and probably would be counterproductive.

Yes I have some problems with sessions not working when I
switch to using the builtin server (instead of apache under
a registered domain) under localhost (for testing changes).

| A sane default for cookie_domain would be something as
| $cd = (/(\.[^\.]+\.[^\.]+)$/)[0] || $_ for $c->req->uri->host
| giving you
| ".example.com" for "www.example.com" and "www.sub.example.com",
| "example.com" for "example.com" and of course
| "mylocaltestdomain" for "mylocaltestdomain".
| 
| But this is untested yet.

I'd be interested to know how you do that, if your tests are
successful.

Fernan

| -- 
| Bernhard Graf
| 
|
+----]



More information about the Catalyst mailing list