Apache2-WebApp-Plugin-Session-MySQL
view release on metacpan or search on metacpan
34567891011121314151617181920212223abstract: 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
Makefile.PL view on Meta::CPAN
171819202122232425262728293031323334353637WriteMakefile(
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 {
121314151617181920212223242526272829303132DESCRIPTION
Store persistent data in a MySQL database
while
maintaining a stateful
session using web browser cookies.
PREREQUISITES
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
6465666768697071727374757677787980818283
[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
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
8384858687888990919293949596979899100101102103
}
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
109110111112113114115116117118119120121122123124125126127128129my
(
$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
152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
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
194195196197198199200201202203204205206207208209210211212213214
= 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
238239240241242243244245246247248249250251252253254255256257258
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
281282283284285286287288289290291292293294295296297298299300301Store 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
335336337338339340341342343344345346347348349350351352353354355
[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 )