NAME
    Catalyst::Plugin::Session::Store::DBIC - Store your sessions via
    DBIx::Class

SYNOPSIS
        # Create a table in your database for sessions
        CREATE TABLE sessions (
            id           CHAR(72) PRIMARY KEY,
            session_data TEXT,
            expires      INTEGER
        );

        # Create the corresponding table class
        package MyApp::Schema::Session;

        use base qw/DBIx::Class/;

        __PACKAGE__->load_components(qw/Core/);
        __PACKAGE__->table('sessions');
        __PACKAGE__->add_columns(qw/id session_data expires/);
        __PACKAGE__->set_primary_key('id');

        1;

        # In your application
        use Catalyst qw/Session Session::Store::DBIC Session::State::Cookie/;

        __PACKAGE__->config(
            # ... other items ...
            session => {
                dbic_class => 'DBIC::Session',  # Assuming MyApp::Model::DBIC
                expires    => 3600,
            },
        );

        # Later, in a controller action
        $c->session->{foo} = 'bar';

DESCRIPTION
    This Catalyst::Plugin::Session storage module saves session data in your
    database via DBIx::Class.

METHODS
  setup_session
    Verify that the configuration is valid, i.e. that a value for the
    "dbic_class" configuration parameter is provided.

  setup_finished
    Hook into the configured session class.

  get_session_data
    (Required method for a Catalyst::Plugin::Session::Store.) Return data
    for the specified session key. Note that session expiration data is
    stored alonside the session itself.

  store_session_data
    (Required method for a Catalyst::Plugin::Session::Store.) Store the
    specified data for the specified session. Session expiration data is
    stored alongside the session itself.

  delete_session_data
    (Required method for a Catalyst::Plugin::Session::Store.) Delete the
    specified session from the backend store.

  delete_expired_sessions
    (Required method for a Catalyst::Plugin::Session::Store.) Delete all
    expired sessions.

CONFIGURATION
    The following parameters should be placed in your application
    configuration under the "session" key.

  dbic_class
    (Required) The name of the DBIx::Class that represents a session in the
    database. It is recommended that you provide only the part after
    "MyApp::Model", e.g. "DBIC::Session".

    If you are using Catalyst::Model::DBIC::Schema, the following layout is
    recommended:

    * "MyApp::Schema" - your DBIx::Class::Schema class
    * "MyApp::Schema::Session" - your session table class
    * "MyApp::Model::DBIC" - your Catalyst::Model::DBIC::Schema class

    This module will then use "$c->model" to access the appropriate result
    source from the composed schema matching the "dbic_class" name.

    For more information, please see Catalyst::Model::DBIC::Schema.

  expires
    Number of seconds for which sessions are active.

    Note that no automatic cleanup is done on your session data. To delete
    expired sessions, you can use the "delete_expired_sessions" method with
    Catalyst::Plugin::Scheduler.

  id_field
    The name of the field on your sessions table which stores the session
    ID. Defaults to "id".

  data_field
    The name of the field on your sessions table which stores session data.
    Defaults to "session_data" for compatibility with
    Catalyst::Plugin::Session::Store::DBI.

  expires_field
    The name of the field on your sessions table which stores the expiration
    time of the session. Defaults to "expires".

SCHEMA
    Your sessions table should contain the following columns:

        id           CHAR(72) PRIMARY KEY
        session_data TEXT
        expires      INTEGER

    The "id" column should probably be 72 characters. It needs to handle the
    longest string that can be returned by "generate_session_id" in
    Catalyst::Plugin::Session, plus another eight characters for internal
    use. This is less than 72 characters when SHA-1 or MD5 is used, but
    SHA-256 will need all 72 characters.

    The "session_data" column should be a long text field. Session data is
    encoded using MIME::Base64 before being stored in the database.

    The "expires" column stores the future expiration time of the session.
    This may be null for per-user and flash sessions.

    Note that you can change the column names using the "id_field",
    "data_field", and "expires_field" configuration parameters. However, the
    column types must match the above.

AUTHOR
    Daniel Westermann-Clark <danieltwc@cpan.org>

ACKNOWLEDGMENTS
    * Andy Grundman, for Catalyst::Plugin::Session::Store::DBI
    * David Kamholz, for most of the testing code (from
    Catalyst::Plugin::Authentication::Store::DBIC)

COPYRIGHT
    Copyright 2006 Daniel Westermann-Clark, all rights reserved.

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