App::ZofCMS::Plugin::Session - plugin for storing data across requests
plugins => [ { Session => 2000 }, { Sub => 3000 }, ], plugins2 => [ qw/Session/, ], plug_session => { dsn => "DBI:mysql:database=test;host=localhost", user => 'test', pass => 'test', }, plug_sub => sub { my $t = shift; $t->{d}{session}{time} = localtime; },
The module is a plugin for App::ZofCMS that provides means to store data across HTTP requests.
The docs for this plugin are incomplete
This plugin requires ZofCMS version of at least 0.0211 where multi-level plugin sets are implemented
This documentation assumes you've read App::ZofCMS, App::ZofCMS::Config and App::ZofCMS::Template
plugins
plugins => [ qw/Session/, ], plugins2 => [ qw/Session/, ],
Important. This plugin requires to be executed twice. On first execution [currently] it will load the session data into $t->{d}{session}
where $t
is ZofCMS Template hashref. On second execution, it will save that data into an SQL table.
plug_session
plug_session => { dsn => "DBI:mysql:database=test;host=localhost", user => 'test', pass => 'test', opt => { RaiseError => 1, AutoCommit => 1 }, create_table => 1, },
Mandatory. The plug_session
key takes a hashref as a value. The possible keys/values of that hashref are described below. There are quite a few more options to come - see source code - but those are untested and may be changed, thus use them at your own risk.
dsn
dsn => "DBI:mysql:database=test;host=localhost",
Mandatory. Specifies the DSN for database, see DBI for more information on what to use here.
user
and pass
user => 'test', pass => 'test',
Semi-optional. The user
and pass
key should contain username and password for the SQL database that plugin will use. Defaults are: user
is root
and pass
is set to undef
.
opt
opt => { RaiseError => 1, AutoCommit => 0 },
The opt
key takes a hashref of any additional options you want to pass to connect_cached
DBI's method.
Defaults to: { RaiseError => 1, AutoCommit => 0 },
table
table => 'session',
Optional. Takes a string as a value. Specifies the name of the SQL table that plugin will use to store data. Defaults to: session
create_table
create_table => 1,
Optional. Takes either true or false values. When set to a true value, the plugin will automatically create the database table that it nees for operation. Defaults to: 0
. Here is the table that it creates ($conf{table}
is the table
plugin's argument):
CREATE TABLE `$conf{table}` ( `id` TEXT, `time` VARCHAR(10), `data` TEXT );
Currently just store your data in $t->{d}{session}
. I suggest you use it as a hashref.
More options to come soon!
See source code, much of it is understandable (e.g. that session cookies last for 24 hours). I'll write better documentation once I get more time.
Fork this module on GitHub: https://github.com/zoffixznet/App-ZofCMS
To report bugs or request features, please use https://github.com/zoffixznet/App-ZofCMS/issues
If you can't access GitHub, you can email your request to bug-App-ZofCMS at rt.cpan.org
Zoffix Znet <zoffix at cpan.org> (http://zoffix.com/, http://haslayout.net/)
You can use and distribute this module under the same terms as Perl itself. See the LICENSE
file included in this distribution for complete details.