sub finalize {
my ($self, $id, $res, $options) = @_;
- $self->_set_cookie($id, $res, (defined $self->expires ? (expires => $self->expires) : ()));
+ $self->_set_cookie($id, $res, (defined $self->expires ? (expires => time + $self->expires) : ()));
}
sub _set_cookie {
=item B<expires>
-Expiration time of the cookie, if nothing is supplied then it will
-not be included in the cookie.
+Expiration time of the cookie in seconds, if nothing is supplied then
+it will not be included in the cookie, which means the session expires
+per browser session.
=item B<secure>
return [ 200, [], [ "counter=$counter" ] ];
};
-$app = Plack::Middleware::Session::Cookie->wrap($app, secret => "foobar");
+$app = Plack::Middleware::Session::Cookie->wrap($app, secret => "foobar", expires => 3600);
my $ua = LWP::UserAgent->new;
$ua->cookie_jar( HTTP::Cookies->new );
my $res = $cb->(GET "/");
is $res->content, "counter=0";
+ like $res->header('Set-Cookie'), qr/expires=/;
$res = $cb->(GET "/");
is $res->content, "counter=1";
+ like $res->header('Set-Cookie'), qr/expires=/;
$res = $cb->(GET "/");
is $res->content, "counter=2";