| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Plack::Session::State::Cookie; |
|
2
|
11
|
|
|
11
|
|
168576
|
use strict; |
|
|
11
|
|
|
|
|
18
|
|
|
|
11
|
|
|
|
|
414
|
|
|
3
|
11
|
|
|
11
|
|
51
|
use warnings; |
|
|
11
|
|
|
|
|
17
|
|
|
|
11
|
|
|
|
|
608
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.23'; |
|
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:STEVAN'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
11
|
|
|
11
|
|
461
|
use parent 'Plack::Session::State'; |
|
|
11
|
|
|
|
|
279
|
|
|
|
11
|
|
|
|
|
82
|
|
|
9
|
11
|
|
|
11
|
|
5750
|
use Cookie::Baker; |
|
|
11
|
|
|
|
|
13066
|
|
|
|
11
|
|
|
|
|
708
|
|
|
10
|
11
|
|
|
11
|
|
2841
|
use Plack::Util; |
|
|
11
|
|
|
|
|
11884
|
|
|
|
11
|
|
|
|
|
346
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
11
|
|
|
|
|
65
|
use Plack::Util::Accessor qw[ |
|
13
|
|
|
|
|
|
|
path |
|
14
|
|
|
|
|
|
|
domain |
|
15
|
|
|
|
|
|
|
expires |
|
16
|
|
|
|
|
|
|
secure |
|
17
|
|
|
|
|
|
|
httponly |
|
18
|
11
|
|
|
11
|
|
74
|
]; |
|
|
11
|
|
|
|
|
17
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub get_session_id { |
|
21
|
24
|
|
|
24
|
1
|
30
|
my ($self, $env) = @_; |
|
22
|
24
|
|
|
|
|
70
|
crush_cookie($env->{HTTP_COOKIE})->{$self->session_key}; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub merge_options { |
|
26
|
27
|
|
|
27
|
0
|
90
|
my($self, %options) = @_; |
|
27
|
|
|
|
|
|
|
|
|
28
|
27
|
|
|
|
|
45
|
delete $options{id}; |
|
29
|
|
|
|
|
|
|
|
|
30
|
27
|
100
|
100
|
|
|
99
|
$options{path} = $self->path || '/' if !exists $options{path}; |
|
31
|
27
|
100
|
100
|
|
|
217
|
$options{domain} = $self->domain if !exists $options{domain} && defined $self->domain; |
|
32
|
27
|
100
|
100
|
|
|
194
|
$options{secure} = $self->secure if !exists $options{secure} && defined $self->secure; |
|
33
|
27
|
50
|
66
|
|
|
199
|
$options{httponly} = $self->httponly if !exists $options{httponly} && defined $self->httponly; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
27
|
100
|
100
|
|
|
174
|
if (!exists $options{expires} && defined $self->expires) { |
|
37
|
2
|
|
|
|
|
14
|
$options{expires} = time + $self->expires; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
27
|
|
|
|
|
171
|
return %options; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub expire_session_id { |
|
44
|
2
|
|
|
2
|
1
|
10
|
my ($self, $id, $res, $options) = @_; |
|
45
|
2
|
|
|
|
|
9
|
my %opts = $self->merge_options(%$options, expires => time); |
|
46
|
2
|
|
|
|
|
8
|
$self->_set_cookie($id, $res, %opts); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub finalize { |
|
50
|
22
|
|
|
22
|
1
|
97
|
my ($self, $id, $res, $options) = @_; |
|
51
|
22
|
|
|
|
|
68
|
my %opts = $self->merge_options(%$options); |
|
52
|
22
|
|
|
|
|
62
|
$self->_set_cookie($id, $res, %opts); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _set_cookie { |
|
56
|
24
|
|
|
24
|
|
37
|
my($self, $id, $res, %options) = @_; |
|
57
|
|
|
|
|
|
|
|
|
58
|
24
|
|
|
|
|
48
|
my $cookie = bake_cookie( |
|
59
|
|
|
|
|
|
|
$self->session_key, { |
|
60
|
|
|
|
|
|
|
value => $id, |
|
61
|
|
|
|
|
|
|
%options, |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
); |
|
64
|
24
|
|
|
|
|
1011
|
Plack::Util::header_push($res->[1], 'Set-Cookie', $cookie); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |