line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Ado::Sessions::Database; |
2
|
14
|
|
|
14
|
|
890
|
use Mojo::Base 'Ado::Sessions'; |
|
14
|
|
|
|
|
23
|
|
|
14
|
|
|
|
|
99
|
|
3
|
14
|
|
|
14
|
|
2557
|
use Mojo::JSON; |
|
14
|
|
|
|
|
22
|
|
|
14
|
|
|
|
|
823
|
|
4
|
14
|
|
|
14
|
|
69
|
use Mojo::Util qw(slurp spurt b64_decode b64_encode); |
|
14
|
|
|
|
|
23
|
|
|
14
|
|
|
|
|
1081
|
|
5
|
14
|
|
|
14
|
|
866
|
use Ado::Model::Sessions; |
|
14
|
|
|
|
|
24
|
|
|
14
|
|
|
|
|
4869
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub load { |
8
|
123
|
|
|
123
|
1
|
50836
|
my ($self, $c) = @_; |
9
|
|
|
|
|
|
|
|
10
|
123
|
|
|
|
|
259
|
my $session = {}; |
11
|
123
|
|
100
|
|
|
765
|
my $id = $self->session_id($c) || ''; |
12
|
|
|
|
|
|
|
|
13
|
123
|
100
|
|
|
|
18996
|
if ($id) { |
14
|
63
|
|
|
|
|
567
|
my $adosession = Ado::Model::Sessions->find($id); |
15
|
63
|
50
|
|
|
|
11455
|
if ($adosession->data) { |
16
|
|
|
|
|
|
|
return |
17
|
63
|
50
|
|
|
|
9919
|
unless $session = Mojo::JSON::j(b64_decode $adosession->sessiondata); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
123
|
|
|
|
|
16805
|
return $self->prepare_load($c, $session); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub store { |
25
|
111
|
|
|
111
|
1
|
137835
|
my ($self, $c) = @_; |
26
|
|
|
|
|
|
|
|
27
|
111
|
|
|
|
|
900
|
my ($id, $session) = $self->prepare_store($c); |
28
|
111
|
100
|
|
|
|
474
|
return unless $id; |
29
|
78
|
|
|
|
|
455
|
my $value = b64_encode(Mojo::JSON::encode_json($session), ''); |
30
|
78
|
|
|
|
|
10828
|
my $adosession = Ado::Model::Sessions->find($id); |
31
|
78
|
100
|
|
|
|
13463
|
if ($adosession->data) { |
32
|
63
|
|
|
|
|
9217
|
$adosession->sessiondata($value)->update(); |
33
|
63
|
|
|
|
|
18930
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
15
|
|
|
|
|
1777
|
Ado::Model::Sessions->create(id => $id, tstamp => time(), sessiondata => $value); |
36
|
|
|
|
|
|
|
|
37
|
15
|
|
|
|
|
79
|
return; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=pod |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=encoding UTF-8 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Ado::Sessions::Database - manage sessions stored in the database |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 DESCRIPTION |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
L manages sessions for |
53
|
|
|
|
|
|
|
L. All data gets serialized with L and stored |
54
|
|
|
|
|
|
|
C encoded in the database. A cookie or a request parameter can |
55
|
|
|
|
|
|
|
be used to share the session id between the server and the user agents. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 METHODS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 load |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Load session data from database. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 store |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Save session data in database. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SEE ALSO |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
L, L |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |