Apache2-WebApp-Plugin-Session-MySQL

 view release on metacpan or  search on metacpan

META.yml  view on Meta::CPAN

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
abstract: Store session data in a MySQL database
version: 0.12
author:
  - Marc S. Brooks <mbrooks@cpan.org>
license: perl
distribution_type: module
requires:
  Apache::Session::MySQL: 1.01
  Apache::Session::Lock::MySQL: 1.01
  Apache2::WebApp: 0.38
  Apache2::WebApp::Plugin::Cookie: 0.09
  Apache2::WebApp::Plugin::DBI: 0.09
  Apache2::WebApp::Plugin::Session: 0.14
  Params::Validate: 0
build_requires:
  Apache::Test: 0
resources:
meta-spec:
  version: 1.3

Makefile.PL  view on Meta::CPAN

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
WriteMakefile(
    NAME         => 'Apache2::WebApp::Plugin::Session::MySQL',
    VERSION_FROM => 'lib/Apache2/WebApp/Plugin/Session/MySQL.pm', # finds \$VERSION
    AUTHOR       => 'Marc S. Brooks (mbrooks@cpan.org)',
    PREREQ_PM => {
        'Apache::Test'                     => 0,
        'Apache::Session::MySQL'           => 1.01,
        'Apache::Session::Lock::MySQL'     => 1.01,
        'Apache2::WebApp'                  => 0.38,
        'Apache2::WebApp::Plugin::Cookie'  => 0.09,
        'Apache2::WebApp::Plugin::DBI'     => 0.09,
        'Apache2::WebApp::Plugin::Session' => 0.14,
        'Params::Validate'                 => 0,
    },
    clean => {
        FILES => "@{ clean_files() }",
    }
);
 
sub clean_files {

README  view on Meta::CPAN

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
DESCRIPTION
    Store persistent data in a MySQL database while maintaining a stateful
    session using web browser cookies.
 
PREREQUISITES
    This package is part of a larger distribution and was NOT intended to be
    used directly. In order for this plugin to work properly, the following
    packages must be installed:
 
      Apache2::WebApp
      Apache2::WebApp::Plugin::Cookie
      Apache2::WebApp::Plugin::DBI
      Apache2::WebApp::Plugin::Session
      Params::Validate
 
INSTALLATION
    From source:
 
      $ tar xfz Apache2-WebApp-Plugin-Session-MySQL-0.X.X.tar.gz
      $ perl MakeFile.PL PREFIX=~/path/to/custom/dir LIB=~/path/to/custom/lib
      $ make

README  view on Meta::CPAN

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
      [session]
      storage_type = mysql
      expires = 1h
 
OBJECT METHODS
    Please refer to Apache2::WebApp::Session for method info.
 
SEE ALSO
    Apache2::WebApp, Apache2::WebApp::Plugin,
    Apache2::WebApp::Plugin::Cookie, Apache2::WebApp::Plugin::DBI,
    Apache2::WebApp::Plugin::Session, Apache::Session,
    Apache::Session::MySQL, Apache::Session::Lock::MySQL
 
AUTHOR
    Marc S. Brooks, <mbrooks@cpan.org> - <http://mbrooks.info>
 
COPYRIGHT
    This program is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

lib/Apache2/WebApp/Plugin/Session/MySQL.pm  view on Meta::CPAN

83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
    }
 
    foreach my $key (keys %$data_ref) {
        $session{$key} = $data_ref->{$key};     # merge hash key/values
    }
 
    my $id = $session{_session_id};
 
    untie %session;
 
    $c->plugin('Cookie')->set( $c, {
        name    => $name,
        value   => $id,
        expires => $c->config->{session_expires} || '24h',
      });
 
    return $id;
}
 
#----------------------------------------------------------------------------+
# get( \%controller, $arg )

lib/Apache2/WebApp/Plugin/Session/MySQL.pm  view on Meta::CPAN

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
my ( $self, $c, $arg )
  = validate_pos( @_,
      { type => OBJECT  },
      { type => HASHREF },
      { type => SCALAR  }
      );
 
$self->error('Malformed session identifier')
  unless ( $arg =~ /^[\w-]{1,32}$/ );
 
my $cookie = $c->plugin('Cookie')->get($arg);
 
my $id = ($cookie) ? $cookie : $arg;
 
my $dbh = $c->stash('DBH');     # use an existing connection
 
my %session;
 
eval {
    tie %session, 'Apache::Session::MySQL', $id, {
        Handle     => $dbh,

lib/Apache2/WebApp/Plugin/Session/MySQL.pm  view on Meta::CPAN

152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
    my ( $self, $c, $arg )
      = validate_pos( @_,
          { type => OBJECT  },
          { type => HASHREF },
          { type => SCALAR  }
          );
 
    $self->error('Malformed session identifier')
      unless ( $arg =~ /^[\w-]{1,32}$/ );
 
    my $cookie = $c->plugin('Cookie')->get($arg);
 
    my $id = ($cookie) ? $cookie : $arg;
 
    my $dbh = $c->stash('DBH');     # use an existing connection
 
    my %session;
 
    eval {
        tie %session, 'Apache::Session::MySQL', $id, {
            Handle     => $dbh,
            LockHandle => $dbh,
          };
      };
 
    unless ($@) {
        tied(%session)->delete;
 
        $c->plugin('Cookie')->delete( $c, $arg );
    }
 
    return;
}
 
#----------------------------------------------------------------------------+
# update( \%controller, $arg, \%data );
#
# Takes the cookie unique identifier or session id as arguments.  Updates
# existing session data.

lib/Apache2/WebApp/Plugin/Session/MySQL.pm  view on Meta::CPAN

194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
  = validate_pos( @_,
      { type => OBJECT  },
      { type => HASHREF },
      { type => SCALAR  },
      { type => HASHREF }
      );
 
$self->error('Malformed session identifier')
  unless ( $arg =~ /^[\w-]{1,32}$/ );
 
my $cookie = $c->plugin('Cookie')->get($arg);
 
my $id = ($cookie) ? $cookie : $arg;
 
my $dbh = $c->stash('DBH');     # use an existing connection
 
my %session;
 
eval {
    tie %session, 'Apache::Session::MySQL', $id, {
        Handle     => $dbh,

lib/Apache2/WebApp/Plugin/Session/MySQL.pm  view on Meta::CPAN

238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
    my ( $self, $c, $name )
      = validate_pos( @_,
          { type => OBJECT  },
          { type => HASHREF },
          { type => SCALAR  }
          );
 
    $self->error('Malformed session identifier')
      unless ( $name =~ /^[\w-]{1,32}$/ );
 
    return $c->plugin('Cookie')->get($name);
}
 
#~~~~~~~~~~~~~~~~~~~~~~~~~~[  PRIVATE METHODS  ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
 
#----------------------------------------------------------------------------+
# _init(\%params)
#
# Return a reference of $self to the caller.
 
sub _init {

lib/Apache2/WebApp/Plugin/Session/MySQL.pm  view on Meta::CPAN

281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
Store persistent data in a MySQL database while maintaining a stateful session
using web browser cookies.
 
=head1 PREREQUISITES
 
This package is part of a larger distribution and was NOT intended to be used
directly.  In order for this plugin to work properly, the following packages
must be installed:
 
  Apache2::WebApp
  Apache2::WebApp::Plugin::Cookie
  Apache2::WebApp::Plugin::DBI
  Apache2::WebApp::Plugin::Session
  Params::Validate
 
=head1 INSTALLATION
 
From source:
 
  $ tar xfz Apache2-WebApp-Plugin-Session-MySQL-0.X.X.tar.gz
  $ perl MakeFile.PL PREFIX=~/path/to/custom/dir LIB=~/path/to/custom/lib

lib/Apache2/WebApp/Plugin/Session/MySQL.pm  view on Meta::CPAN

335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
  [session]
  storage_type = mysql
  expires = 1h
 
=head1 OBJECT METHODS
 
Please refer to L<Apache2::WebApp::Session> for method info.
 
=head1 SEE ALSO
 
L<Apache2::WebApp>, L<Apache2::WebApp::Plugin>, L<Apache2::WebApp::Plugin::Cookie>,
L<Apache2::WebApp::Plugin::DBI>, L<Apache2::WebApp::Plugin::Session>,
L<Apache::Session>, L<Apache::Session::MySQL>, L<Apache::Session::Lock::MySQL>
 
=head1 AUTHOR
 
Marc S. Brooks, E<lt>mbrooks@cpan.orgE<gt> - L<http://mbrooks.info>
 
=head1 COPYRIGHT
 
This program is free software; you can redistribute it and/or modify it



( run in 0.231 second using v1.01-cache-2.11-cpan-454fe037f31 )