NAME
Catalyst::Plugin::Session::Store::Jifty::DBI - Store your session with Jifty::DBI
SYNOPSIS
# 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
DESCRIPTION
This storage module will store session data in a database using a Jifty::DBI model.
CONFIGURATION
These parameters are placed in the configuration hash under the session
key.
expires
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.
moniker
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).
columns
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',
},
});
use_custom_serialization
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.
METHODS
get_session_data
store_session_data
delete_session_data
delete_expired_sessions
setup_session
These are implementations of the required methods for a store. See Catalyst::Plugin::Session::Store.
SEE ALSO
Catalyst::Plugin::Session, Catalyst::Plugin::Session::Store::DBI, Catalyst::Plugin::Session::Store::DOD
AUTHOR
Kenichi Ishigaki, <ishigaki@cpan.org>
COPYRIGHT AND LICENSE
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.