.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Catalyst::Plugin::Session::Store::DBIC 3pm" .TH Catalyst::Plugin::Session::Store::DBIC 3pm "2022-06-09" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Catalyst::Plugin::Session::Store::DBIC \- Store your sessions via DBIx::Class .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 6 \& # 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(\*(Aqsessions\*(Aq); \& _\|_PACKAGE_\|_\->add_columns(qw/id session_data expires/); \& _\|_PACKAGE_\|_\->set_primary_key(\*(Aqid\*(Aq); \& \& 1; \& \& # In your application \& use Catalyst qw/Session Session::Store::DBIC Session::State::Cookie/; \& \& _\|_PACKAGE_\|_\->config( \& # ... other items ... \& \*(AqPlugin::Session\*(Aq => { \& dbic_class => \*(AqDBIC::Session\*(Aq, # Assuming MyApp::Model::DBIC \& expires => 3600, \& }, \& ); \& \& # Later, in a controller action \& $c\->session\->{foo} = \*(Aqbar\*(Aq; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This Catalyst::Plugin::Session storage module saves session data in your database via DBIx::Class. It's actually just a wrapper around Catalyst::Plugin::Session::Store::Delegate; if you need complete control over how your sessions are stored, you probably want to use that instead. .SH "METHODS" .IX Header "METHODS" .SS "setup_finished" .IX Subsection "setup_finished" Hook into the configured session class. .SS "session_store_dbic_class" .IX Subsection "session_store_dbic_class" Return the DBIx::Class class name to be passed to \f(CW\*(C`$c\->model\*(C'\fR. Defaults to \f(CW\*(C`DBIC::Session\*(C'\fR. .SS "session_store_dbic_id_field" .IX Subsection "session_store_dbic_id_field" Return the configured \s-1ID\s0 field name. Defaults to \f(CW\*(C`id\*(C'\fR. .SS "session_store_dbic_data_field" .IX Subsection "session_store_dbic_data_field" Return the configured data field name. Defaults to \f(CW\*(C`session_data\*(C'\fR. .SS "session_store_dbic_expires_field" .IX Subsection "session_store_dbic_expires_field" Return the configured expires field name. Defaults to \f(CW\*(C`expires\*(C'\fR. .SS "session_store_model" .IX Subsection "session_store_model" Return the model used to find a session. .SS "get_session_store_delegate" .IX Subsection "get_session_store_delegate" Load the row corresponding to the specified session \s-1ID.\s0 If none is found, one is automatically created. .SS "session_store_delegate_key_to_accessor" .IX Subsection "session_store_delegate_key_to_accessor" Match the specified key and operation to the session \s-1ID\s0 and field name. .SS "delete_session_data" .IX Subsection "delete_session_data" Delete the specified session from the backend store. .SS "delete_expired_sessions" .IX Subsection "delete_expired_sessions" Delete all expired sessions. .SH "CONFIGURATION" .IX Header "CONFIGURATION" The following parameters should be placed in your application configuration under the \f(CW\*(C`Plugin::Session\*(C'\fR key. .SS "dbic_class" .IX Subsection "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 \&\f(CW\*(C`MyApp::Model\*(C'\fR, e.g. \f(CW\*(C`DBIC::Session\*(C'\fR. .PP If you are using Catalyst::Model::DBIC::Schema, the following layout is recommended: .IP "\(bu" 4 \&\f(CW\*(C`MyApp::Schema\*(C'\fR \- your DBIx::Class::Schema class .IP "\(bu" 4 \&\f(CW\*(C`MyApp::Schema::Session\*(C'\fR \- your session table class .IP "\(bu" 4 \&\f(CW\*(C`MyApp::Model::DBIC\*(C'\fR \- your Catalyst::Model::DBIC::Schema class .PP This module will then use \f(CW\*(C`$c\->model\*(C'\fR to access the appropriate result source from the composed schema matching the \f(CW\*(C`dbic_class\*(C'\fR name. .PP For more information, please see Catalyst::Model::DBIC::Schema. .SS "expires" .IX Subsection "expires" Number of seconds for which sessions are active. .PP Note that no automatic cleanup is done on your session data. To delete expired sessions, you can use the \*(L"delete_expired_sessions\*(R" method with Catalyst::Plugin::Scheduler. .SS "id_field" .IX Subsection "id_field" The name of the field on your sessions table which stores the session \&\s-1ID.\s0 Defaults to \f(CW\*(C`id\*(C'\fR. .SS "data_field" .IX Subsection "data_field" The name of the field on your sessions table which stores session data. Defaults to \f(CW\*(C`session_data\*(C'\fR for compatibility with Catalyst::Plugin::Session::Store::DBI. .SS "expires_field" .IX Subsection "expires_field" The name of the field on your sessions table which stores the expiration time of the session. Defaults to \f(CW\*(C`expires\*(C'\fR. .SH "SCHEMA" .IX Header "SCHEMA" Your sessions table should contain the following columns: .PP .Vb 3 \& id CHAR(72) PRIMARY KEY \& session_data TEXT \& expires INTEGER .Ve .PP The \f(CW\*(C`id\*(C'\fR column should probably be 72 characters. It needs to handle the longest string that can be returned by \&\*(L"generate_session_id\*(R" in Catalyst::Plugin::Session, plus another eight characters for internal use. This is less than 72 characters when \&\s-1SHA\-1\s0 or \s-1MD5\s0 is used, but \s-1SHA\-256\s0 will need all 72 characters. .PP The \f(CW\*(C`session_data\*(C'\fR column should be a long text field. Session data is encoded using MIME::Base64 before being stored in the database. .PP Note that MySQL \f(CW\*(C`TEXT\*(C'\fR fields only store 64 kB, so if your session data will exceed that size you'll want to use \f(CW\*(C`MEDIUMTEXT\*(C'\fR, \&\f(CW\*(C`MEDIUMBLOB\*(C'\fR, or larger. If you configure your DBIx::Class::ResultSource to include the size of the column, you will receive warnings for this problem: .PP .Vb 3 \& This session requires 1180 bytes of storage, but your database \& column \*(Aqsession_data\*(Aq can only store 200 bytes. Storing this \& session may not be reliable; increase the size of your data field .Ve .PP See \*(L"add_columns\*(R" in DBIx::Class::ResultSource for more information. .PP The \f(CW\*(C`expires\*(C'\fR column stores the future expiration time of the session. This may be null for per-user and flash sessions. .PP Note that you can change the column names using the \*(L"id_field\*(R", \&\*(L"data_field\*(R", and \*(L"expires_field\*(R" configuration parameters. However, the column types must match the above. .SH "AUTHOR" .IX Header "AUTHOR" Daniel Westermann-Clark .SH "ACKNOWLEDGMENTS" .IX Header "ACKNOWLEDGMENTS" .IP "\(bu" 4 Andy Grundman, for Catalyst::Plugin::Session::Store::DBI .IP "\(bu" 4 David Kamholz, for most of the testing code (from Catalyst::Plugin::Authentication::Store::DBIC) .IP "\(bu" 4 Yuval Kogman, for assistance in converting to Catalyst::Plugin::Session::Store::Delegate .IP "\(bu" 4 Jay Hannah, for tests and warning when session size exceeds DBIx::Class storage size. .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2006 \- 2009 the Catalyst::Plugin::Session::Store::DBIC \*(L"\s-1AUTHOR\*(R"\s0 as listed above. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.