Apache2-WebApp-Plugin-Session-MySQL
view release on metacpan or search on metacpan
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:
license: http://dev.perl.org/licenses/
meta-spec:
version: 1.3
url: http://module-build.sourceforge.net/META-spec-v1.3.html
Makefile.PL view on Meta::CPAN
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 {
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
[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
}
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
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
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
= 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
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
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
[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.542 second using v1.01-cache-2.11-cpan-ec4f86ec37b )