Index: lib/Catalyst/Plugin/Session/State/Cookie.pm =================================================================== --- lib/Catalyst/Plugin/Session/State/Cookie.pm (revision 10480) +++ lib/Catalyst/Plugin/Session/State/Cookie.pm (working copy) @@ -7,7 +7,7 @@ use MRO::Compat; use Catalyst::Utils (); -our $VERSION = "0.11"; +our $VERSION = "0.12"; BEGIN { __PACKAGE__->mk_accessors(qw/_deleted_session_id/) } @@ -61,9 +61,10 @@ my ( $c, $sid, %attrs ) = @_; my $cfg = $c->config->{session}; + my $cookie_domain = ( ! $cfg->{cookie_domain} ) ? undef : ( ref $cfg->{cookie_domain} eq 'CODE' ) ? $cfg->{cookie_domain}->($c) : $cfg->{cookie_domain}; my $cookie = { value => $sid, - ( $cfg->{cookie_domain} ? ( domain => $cfg->{cookie_domain} ) : () ), + ( $cookie_domain ? ( domain => $cookie_domain ) : () ), ( $cfg->{cookie_path} ? ( path => $cfg->{cookie_path} ) : () ), %attrs, }; @@ -220,6 +221,17 @@ The name of the domain to store in the cookie (defaults to current host) +or more configurable: + + __PACKAGE__->config->{session}->{cookie_domain} = sub { + my $c = shift; + if ( $c->req->uri->host =~ /xxx\.com/ ) { + return '.xxx.com'; + } else { + return '.yyy.com'; + } + }; + =item cookie_expires Number of seconds from now you want to elapse before cookie will expire.