delete $options{id};
- $options{path} = $self->path || '/' if !exists $options{path} && defined $self->path;
+ $options{path} = $self->path || '/' if !exists $options{path};
$options{domain} = $self->domain if !exists $options{domain} && defined $self->domain;
$options{secure} = $self->secure if !exists $options{secure} && defined $self->secure;
$options{httponly} = $self->httponly if !exists $options{httponly} && defined $self->httponly;
+
if (!exists $options{expires} && defined $self->expires) {
$options{expires} = time + $self->expires;
}
my $res = $cb->(GET "/");
is $res->content, "counter=0";
like $res->header('Set-Cookie'), qr/expires=/;
+ like $res->header('Set-Cookie'), qr/path=\//;
$res = $cb->(GET "/");
is $res->content, "counter=1";
$env->{'psgix.session'}->{counter} = 1;
- $env->{'psgix.session.options'}{path} = '/foo';
+ my $path = $env->{PATH_INFO} =~ /with_path/ ? "/foo" : undef;
+ $env->{'psgix.session.options'}{path} = $path;
$env->{'psgix.session.options'}{domain} = '.example.com';
$env->{'psgix.session.options'}{httponly} = 1;
my $cb = shift;
my $res = $cb->(GET "http://localhost/");
+ like $res->header('Set-Cookie'), qr/plack_session=\w+; domain=.example.com; HttpOnly/;
+
+ $res = $cb->(GET "http://localhost/with_path");
like $res->header('Set-Cookie'), qr/plack_session=\w+; domain=.example.com; path=\/foo; HttpOnly/;
};