Skip to content

Commit

Permalink
Implement temporary cookies support
Browse files Browse the repository at this point in the history
  • Loading branch information
faf committed Mar 21, 2013
1 parent d085919 commit ddb5567
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions pulma
Original file line number Diff line number Diff line change
Expand Up @@ -545,17 +545,29 @@ while($request = CGI::Fast->new()) {
# prepare cookies to store
foreach my $cookie (@{$data->{'result'}->{'cookies'}}) {

push(@{$data->{'result'}->{'headers'}->{'-cookie'}},
cookie( -name => $cookie->{'name'} || 'pulma',
-secure => $cookie->{'secure'} || 0,
-httponly => $cookie->{'httponly'} || 0,
-value => exists ($cookie->{'value'}) ?
$cookie->{'value'} :
'pulma',
-path => $cookie->{'path'} || $config->{'map'}->{'root'} ||
'/',
-expires => ($cookie->{'delete'} ? '-' : '+') .
($cookie->{'expires'} || '120') . 's'));
my $structure = { -name => $cookie->{'name'} || 'pulma',
-secure => $cookie->{'secure'} || 0,
-httponly => $cookie->{'httponly'} || 0,
-value => exists ($cookie->{'value'}) ?
$cookie->{'value'} :
'pulma',
-path => $cookie->{'path'} ||
$config->{'map'}->{'root'} ||
'/'
};

if (!exists($cookie->{'expires'})) {
if (exists($cookie->{'delete'})) {
$structure->{-expires} = '-' . 120 . 's';
}
}
else {
$structure->{-expires} = ($cookie->{'delete'} ? '-' : '+') .
$cookie->{'expires'} . 's';
}

push( @{$data->{'result'}->{'headers'}->{'-cookie'}},
cookie( $structure ) );

}

Expand Down

0 comments on commit ddb5567

Please sign in to comment.