NAME

App::ZofCMS::Plugin::Session - plugin for storing data across requests

SYNOPSIS

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;
},

DESCRIPTION

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

FIRST-LEVEL ZofCMS TEMPLATE AND MAIN CONFIG FILE KEYS

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
);

USAGE

Currently just store your data in $t->{d}{session}. I suggest you use it as a hashref.

More options to come soon!

MORE INFO

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.

AUTHOR

'Zoffix, <'zoffix at cpan.org'> (http://zoffix.com/, http://haslayout.net/, http://zofdesign.com/)

BUGS

Please report any bugs or feature requests to bug-app-zofcms-plugin-session at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-ZofCMS-Plugin-Session. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc App::ZofCMS::Plugin::Session

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2008 'Zoffix, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.