Catalyst::Plugin::Session::Store::Jifty::DBI - Store your session with Jifty::DBI
# prepare a table like this. # note that we use "session_id" instead of simple "id", # as "id" is usually reserved as serial by Jifty::DBI # (which is configurable but changing this is not recommended). package MyApp::Schema::Session; use Jifty::DBI::Schema; use Jifty::DBI::Record schema { column session_id => type is 'char(72)', is mandatory, is distinct, is indexed; column session_data => type is 'text'; column expires => type is 'integer'; }; # and a model package MyApp::Model::DB; use base qw( Catalyst::Model::Jifty::DBI ); __PACKAGE__->config->{schema_base} = 'MyApp::Schema'; # and your app. MyApp->config('Plugin::Session' => { expires => 3600, moniker => 'DB::Session', }); # then in an action $c->session->[foo} = 'bar'; # will be saved
This storage module will store session data in a database using a Jifty::DBI model.
These parameters are placed in the configuration hash under the session key.
session
The expires column in your table will be set with the expiration value. Note that no automatic cleanup is done. You can use delete_expired_session method with Catalyst::Plugin::Scheduler, but most probably you may want to implement your own cleanup script with raw Jifty::DBI (or Catalyst::Model::Jifty::DBI) for speed and stability.
expires
delete_expired_session
specify the moniker to access your session table (to get a session record) via $c->model(). This configuration is mandatory. If you dare, you also can set moniker_collection to specify the moniker to get a collection of session records (but you usually don't need this).
moniker_collection
by default, this module uses the column names shown above, but if you want to change some of these, you can give this a hash reference like this:
MyApp->config('Plugin::Session' => { expires => 3600, moniker => 'DB::Session', columns => { id => 'sid', session_data => 'body', expires => 'until', }, });
If you want to use Jifty::DBI::Filters to serialize/deserialize session data, set this to true. This may be handy when you want to use other Jifty::DBI's features like validation.
These are implementations of the required methods for a store. See Catalyst::Plugin::Session::Store.
Catalyst::Plugin::Session, Catalyst::Plugin::Session::Store::DBI, Catalyst::Plugin::Session::Store::DOD
Kenichi Ishigaki, <ishigaki@cpan.org>
Copyright (C) 2008 by Kenichi Ishigaki.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Catalyst::Plugin::Session::Store::Jifty::DBI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Plugin::Session::Store::Jifty::DBI
CPAN shell
perl -MCPAN -e shell install Catalyst::Plugin::Session::Store::Jifty::DBI
For more information on module installation, please visit the detailed CPAN module installation guide.