Mojolicious::Plugin::WWWSession - Use WWWW::Session with Mojolicious
Version 0.05
This module allows you to overwrite the standard Mojolicious session with a WWW::Session object and enjoy all the goodies it provides
Example :
You can use one or more of the fallowing backends :
In you apllication module add the fallowing lines
use Mojolicious::Plugin::WWWSession; sub startup { ... #Overwrite session $self->plugin( WWWSession => { storage => [File => {path => '.'}] } ); ... }
See WWW::Session::Storage::File for more details
use Mojolicious::Plugin::WWWSession; sub startup { ... #Overwrite session $self->plugin( WWWSession => { storage => [ MySQL => { dbh => $dbh, table => 'sessions', fields => { sid => 'session_id', expires => 'expires', data => 'data' } ] } ); ... }
The "fields" hasref contains the mapping of session internal data to the column names from MySQL. The keys are the session fields ("sid","expires" and "data") and must all be present.
The MySQL types of the columns should be :
sid => varchar(32)
expires => DATETIME or TIMESTAMP
data => text
See WWW::Session::Storage::MySQL for more details
use Mojolicious::Plugin::WWWSession; sub startup { ... #Overwrite session $self->plugin( WWWSession => { storage => ['Memcached' => {servers => ['127.0.0.1:11211']}] } ); ... }
See WWW::Session::Storage::Memcached for more details
This session can be used in the exact same way the strandard Mojolicious session is used
Here is an exmple containing the options you can pass to the plugin:
{ storage => [ 'File' => { path => '/tmp/sessions'}, 'Memcached' => { servers => ['127.0.0.1'] } ], serialization => 'JSON', expires => 3600, fields => { user => { inflate => sub { return Some::Package->new( $_[0] ) }, deflate => sub { $_[0]->id() }, } age => { filter => [21..99], } }
See WWW:Session for more details on possible options and on how you can use the session
If you use the "Storable" serialization engine you can store objects in the session. Also multiple session storage backends can be used simultaneously
Called by Mojo when you register the plugin
Gligan Calin Horea, <gliganh at gmail.com>
<gliganh at gmail.com>
Please report any bugs or feature requests to bug-mojolicious-plugin-wwwsession at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Mojolicious-Plugin-WWWSession. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-mojolicious-plugin-wwwsession at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Mojolicious::Plugin::WWWSession
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Mojolicious-Plugin-WWWSession
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Mojolicious-Plugin-WWWSession
CPAN Ratings
http://cpanratings.perl.org/d/Mojolicious-Plugin-WWWSession
Search CPAN
http://search.cpan.org/dist/Mojolicious-Plugin-WWWSession/
Copyright 2012 Gligan Calin Horea.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Mojolicious::Plugin::WWWSession, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::WWWSession
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::WWWSession
For more information on module installation, please visit the detailed CPAN module installation guide.