[Catalyst] Setting cookie_domain

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


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

For example, you can set up an app.yml file in your main
directory with the generic settings (those shared by all
domains). And then place an app_local.yml file besides
the app.ymlm file. This file contains just the overrides for
the domain specific configuration.

So for example, in app.yml you may have:
session:
 dbic_class: mymodel::Sessions
  cookie_name: my_cookie
  expires: 0


and then for each domain you just set the cookie domain.

for domain1, app_local.yml:
session:
dbic_class: mymodel::Sessions
 cookie_domain: my.domain1.com

for domain2, app_local.yml:
session:
 dbic_class: mymodel::Sessions
 cookie_domain: my.domain2.com

With this setup the cookie name and the expiry time are
equal to all domains, only the cookie domain changes.

HTH,

 Fernan

PS: check the docs for the YAML plugin, also the
Catalyst::Manual::Cookbook have some nice examples there
about using YAML to configure your app).



More information about the Catalyst mailing list