Revision history for Perl extension Catalyst::Plugin::Session::State::Cookie
+0.05 2006-08-06 20:50:00
+ - Add configuration of 'cookie_path' (Michael W Peterson)
+
0.04
- Depend on a higher version of C::P::Session
use NEXT;
use Catalyst::Utils ();
-our $VERSION = "0.04";
+our $VERSION = "0.05";
sub setup_session {
my $c = shift;
sub update_session_cookie {
my ( $c, $updated ) = @_;
- my $cookie_name = $c->config->{session}{cookie_name};
- $c->response->cookies->{$cookie_name} = $updated;
+
+ unless ( $c->cookie_is_rejecting( $updated ) ) {
+ my $cookie_name = $c->config->{session}{cookie_name};
+ $c->response->cookies->{$cookie_name} = $updated;
+ }
+}
+
+sub cookie_is_rejecting {
+ my ( $c, $cookie ) = @_;
+
+ if ( $cookie->{path} ) {
+ return 1 if index $c->request->path, $cookie->{path};
+ }
+
+ return 0;
}
sub make_session_cookie {
my $cookie = {
value => $sid,
( $cfg->{cookie_domain} ? ( domain => $cfg->{cookie_domain} ) : () ),
+ ( $cfg->{cookie_path} ? ( path => $cfg->{cookie_path} ) : () ),
%attrs,
};
If this attribute set true, the cookie will only be sent via HTTPS.
+=item cookie_path
+
+The path of the request url where cookie should be baked.
+
=back
=head1 CAVEATS
use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 13;
use Test::MockObject;
use Test::MockObject::Extends;
{ session => { value => $sessionid, expires => 123 } },
"cookie was set correctly"
);
+
+$cxt->clear;
+$req->clear;
+
+can_ok( $m, "cookie_is_rejecting" );
+
+%req_cookies = ( path => '/foo' );
+$req->set_always( path => '/' );
+ok( $cxt->cookie_is_rejecting(\%req_cookies), "cookie is rejecting" );
+$req->set_always( path => '/foo/bar' );
+ok( !$cxt->cookie_is_rejecting(\%req_cookies), "cookie is not rejecting" );