line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Plugin::Session::Manager; |
2
|
1
|
|
|
1
|
|
40057
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
259
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
7
|
use base qw/Class::Data::Inheritable Class::Accessor::Fast/; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
1330
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
24156
|
use NEXT; |
|
1
|
|
|
|
|
16020
|
|
|
1
|
|
|
|
|
71
|
|
8
|
1
|
|
|
1
|
|
4627
|
use UNIVERSAL::require; |
|
1
|
|
|
|
|
1678
|
|
|
1
|
|
|
|
|
10
|
|
9
|
1
|
|
|
1
|
|
27
|
use Digest::MD5; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
10
|
1
|
|
|
1
|
|
573
|
use Catalyst::Exception; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata( '_session' ); |
15
|
|
|
|
|
|
|
__PACKAGE__->mk_classdata( '_session_client' ); |
16
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( 'sessionid' ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub finalize { |
19
|
|
|
|
|
|
|
my $c = shift; |
20
|
|
|
|
|
|
|
$c->_session->set($c); |
21
|
|
|
|
|
|
|
$c->_session_client->set($c); |
22
|
|
|
|
|
|
|
return $c->NEXT::finalize(@_); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub prepare_parameters { |
26
|
|
|
|
|
|
|
my $c = shift; |
27
|
|
|
|
|
|
|
$c->NEXT::prepare_parameters; |
28
|
|
|
|
|
|
|
if ( my $sid = $c->_session_client->get($c) ) { |
29
|
|
|
|
|
|
|
$c->sessionid($sid); |
30
|
|
|
|
|
|
|
$c->log->debug(qq/Found sessionid "$sid"/) if $c->debug; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
return $c; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub session { |
36
|
|
|
|
|
|
|
my $c = shift; |
37
|
|
|
|
|
|
|
return $c->{session} if $c->{session}; |
38
|
|
|
|
|
|
|
my $sid = $c->sessionid; |
39
|
|
|
|
|
|
|
if ( $sid |
40
|
|
|
|
|
|
|
&& $c->_session |
41
|
|
|
|
|
|
|
&& ( $c->{session} = $c->_session->get($sid) ) ) |
42
|
|
|
|
|
|
|
{ |
43
|
|
|
|
|
|
|
$c->log->debug(qq/Found session "$sid"/) if $c->debug; |
44
|
|
|
|
|
|
|
return $c->{session}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
|
|
|
|
|
|
my $sid = Digest::MD5::md5_hex( time, rand, $$, 'catalyst' ); |
48
|
|
|
|
|
|
|
$c->sessionid($sid); |
49
|
|
|
|
|
|
|
$c->log->debug(qq/Created session "$sid"/) if $c->debug; |
50
|
|
|
|
|
|
|
return $c->{session} = {}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub setup { |
55
|
|
|
|
|
|
|
my $self = shift; |
56
|
|
|
|
|
|
|
my $config = $self->config->{session}; |
57
|
|
|
|
|
|
|
my $storage = delete $config->{ storage } || 'FastMmap'; |
58
|
|
|
|
|
|
|
my $client = delete $config->{ client } || 'Cookie'; |
59
|
|
|
|
|
|
|
$storage = 'Catalyst::Plugin::Session::Manager::Storage::'.$storage; |
60
|
|
|
|
|
|
|
$client = 'Catalyst::Plugin::Session::Manager::Client::'.$client; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
$storage->require; |
63
|
|
|
|
|
|
|
if ($@) { |
64
|
|
|
|
|
|
|
Catalyst::Exception->throw( |
65
|
|
|
|
|
|
|
qq/failed to load session storage class "$storage"/ |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
$self->_session($storage->new($config)); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$client->require; |
71
|
|
|
|
|
|
|
if ($@) { |
72
|
|
|
|
|
|
|
Catalyst::Exception->throw( |
73
|
|
|
|
|
|
|
qq/failed to load session client class "$client"/ |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
$self->_session_client($client->new($config)); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return $self->NEXT::setup(@_); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
__END__ |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Catalyst::Plugin::Session::Manager - session manager for Catalyst (deprecated on 5.5) |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SYNOPSIS |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
use Catalyst qw/Session::Manager/; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
MyApp->config->{session} = { |
93
|
|
|
|
|
|
|
storage => 'FastMmap', |
94
|
|
|
|
|
|
|
client => 'Cookie', |
95
|
|
|
|
|
|
|
...other configuration needed by storage and client class. |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 ATTENTION |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
If you use Catalyst 5.5 or later, You should use L<Catalyst::Plugin::Session>. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
I keep this on CPAN just for people still need Catalyst version 5.3. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 DESCRIPTION |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
This module provides session handlers for separated two processes, |
107
|
|
|
|
|
|
|
one is to store data on server-side, another is on client-side. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Set manager on server-side with 'storage' parameter in configuration. |
110
|
|
|
|
|
|
|
And set client-side manager with 'client'. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
If you don't set them, 'FastMmap' and 'Cookie' are set by default. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SERVER SIDE STORAGE |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=over 4 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item FastMmap |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
See L<Catalyst::Plugin::Session::Manager::Storage::FastMmap> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item File |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
See L<Catalyst::Plugin::Session::Manager::Storage::File> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item CDBI |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
See L<Catalyst::Plugin::Session::Manager::Storage::CDBI> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=back |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 CLIENT SIDE HANDLER |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=over 4 |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item Cookie |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
See L<Catalyst::Plugin::Session::Manager::Client::Cookie> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item StickyQuery |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
See L<Catalyst::Plugin::Session::Manager::Client::StickyQuery> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item Rewrite |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
See L<Catalyst::Plugin::Session::Manager::Client::Rewrite> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=back |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 TODO |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=over 4 |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item more documentation |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item more tests |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 SEE ALSO |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
L<Catalyst>, |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
L<Catalyst::Plugin::Session::FastMmap> |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 AUTHOR |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Lyo Kato E<lt>lyo.kato@gmail.comE<gt> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Copyright (C) 2005 by Lyo Kato |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
175
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=cut |
178
|
|
|
|
|
|
|
|