Add support for browser-session cookies, using a cookieTTL value of

"session".
This commit is contained in:
Drake 2006-09-21 18:42:41 +00:00
parent 31cbd665e6
commit a170904340
3 changed files with 9 additions and 3 deletions

View file

@ -241,13 +241,16 @@ sub getCookieName {
=head2 getCookieTTL ( )
Returns the cookie time to live defined in the config file. Returns "10y" if one isn't defined.
Returns the cookie time to live defined in the config file. Returns "+10y" if one isn't defined.
This may also be "session" to indicate that the cookie should only live for the current browser
session.
=cut
sub getCookieTTL {
my $self = shift;
return $self->get("cookieTTL") || "+10y";
my $configTTL = $self->get("cookieTTL");
return defined($configTTL)? $configTTL : "+10y";
}
#-------------------------------------------------------------------

View file

@ -271,6 +271,7 @@ The value to set.
=head3 timeToLive
The time that the cookie should remain in the browser. Defaults to "+10y" (10 years from now).
This may be "session" to indicate that the cookie is for the current browser session only.
=head3 domain
@ -291,9 +292,10 @@ sub setCookie {
my $cookie = Apache2::Cookie->new($self->session->request,
-name=>$name,
-value=>$value,
-expires=>$ttl,
-path=>'/'
);
$cookie->expires($ttl) if $ttl ne 'session';
$cookie->domain($domain) if ($domain);
$cookie->bake($self->session->request);
}