.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" 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 .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Catalyst::Plugin::Session::Store::DBI 3pm" .TH Catalyst::Plugin::Session::Store::DBI 3pm "2018-06-08" "perl v5.26.2" "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::DBI \- Store your sessions in a database .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 int(10) \& ); \& \& # In your app \& use Catalyst qw/Session Session::Store::DBI Session::State::Cookie/; \& \& # Connect directly to the database \& MyApp\->config(\*(AqPlugin::Session\*(Aq => { \& expires => 3600, \& dbi_dsn => \*(Aqdbi:mysql:database\*(Aq, \& dbi_user => \*(Aqfoo\*(Aq, \& dbi_pass => \*(Aqbar\*(Aq, \& dbi_table => \*(Aqsessions\*(Aq, \& dbi_id_field => \*(Aqid\*(Aq, \& dbi_data_field => \*(Aqsession_data\*(Aq, \& dbi_expires_field => \*(Aqexpires\*(Aq, \& }); \& \& # Or use an existing database handle from a DBIC/CDBI class \& MyApp\->config(\*(AqPlugin::Session\*(Aq => { \& expires => 3600, \& dbi_dbh => \*(AqDBIC\*(Aq, # which means MyApp::Model::DBIC \& dbi_table => \*(Aqsessions\*(Aq, \& dbi_id_field => \*(Aqid\*(Aq, \& dbi_data_field => \*(Aqsession_data\*(Aq, \& dbi_expires_field => \*(Aqexpires\*(Aq, \& }); \& \& # ... in an action: \& $c\->session\->{foo} = \*(Aqbar\*(Aq; # will be saved .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This storage module will store session data in a database using \s-1DBI.\s0 .SH "CONFIGURATION" .IX Header "CONFIGURATION" These parameters are placed in the configuration hash under the \f(CW\*(C`Plugin::Session\*(C'\fR key. .SS "expires" .IX Subsection "expires" The expires column in your table will be set with the expiration value. Note that no automatic cleanup is done on your session data, but you can use the delete_expired_sessions method to perform clean up. You can make use of the Catalyst::Plugin::Scheduler plugin to schedule automated session cleanup. .SS "dbi_dbh" .IX Subsection "dbi_dbh" Set this to an existing \f(CW$dbh\fR or the class name of a DBIx::Class, Class::DBI, Rose::DB::Object, or Catalyst::Model::DBI model. DBIx::Class schema is also supported by setting dbi_dbh to the name of your schema model. .PP This method is recommended if you have other database code in your application as it will avoid opening additional connections. .SS "dbi_dsn" .IX Subsection "dbi_dsn" .SS "dbi_user" .IX Subsection "dbi_user" .SS "dbi_pass" .IX Subsection "dbi_pass" .SS "dbi_options" .IX Subsection "dbi_options" To connect directly to a database, specify the necessary dbi_dsn, dbi_user, and dbi_pass options. If you need to supply your own options to \s-1DBI,\s0 you may do so by passing a hashref to dbi_options. The default options are AutoCommit => 1 and RaiseError => 1. .SS "dbi_table" .IX Subsection "dbi_table" Enter the table name within your database where sessions will be stored. This table must have at least 3 columns, id, session_data, and expires. See the Schema section below for additional details. The table name defaults to 'sessions'. .SS "dbi_id_field" .IX Subsection "dbi_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 "dbi_data_field" .IX Subsection "dbi_data_field" The name of the field on your sessions table which stores session data. Defaults to \f(CW\*(C`session_data\*(C'\fR. .SS "dbi_expires_field" .IX Subsection "dbi_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 must contain at minimum the following 3 columns: .PP .Vb 3 \& id char(72) primary key \& session_data text \& expires int(10) .Ve .PP The 'id' 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::Authentication, plus another 8 characters for internal use. This is less than 72 characters in practice when \&\s-1SHA\-1\s0 or \s-1MD5\s0 are used, but \s-1SHA\-256\s0 will need all those characters. .PP The 'session_data' column should be a long text field. Session data is encoded using Base64 before being stored in the database. .PP Note that MySQL \s-1TEXT\s0 fields only store 64KB, so if your session data will exceed that size you'll want to move to \s-1MEDIUMTEXT, MEDIUMBLOB,\s0 or larger. .PP The 'expires' column stores the future expiration time of the session. This may be null for per-user and flash sessions. .PP \&\s-1NOTE:\s0 Your column names do not need to match with this schema, use config to set custom column names. .SH "METHODS" .IX Header "METHODS" .SS "get_session_data" .IX Subsection "get_session_data" .SS "store_session_data" .IX Subsection "store_session_data" .SS "delete_session_data" .IX Subsection "delete_session_data" .SS "delete_expired_sessions" .IX Subsection "delete_expired_sessions" .SS "setup_session" .IX Subsection "setup_session" These are implementations of the required methods for a store. See Catalyst::Plugin::Session::Store. .SS "session_store_dbi_table" .IX Subsection "session_store_dbi_table" Return the configured table name. .SS "session_store_dbi_id_field" .IX Subsection "session_store_dbi_id_field" Return the configured \s-1ID\s0 field name. .SS "session_store_dbi_data_field" .IX Subsection "session_store_dbi_data_field" Return the configured data field name. .SS "session_store_dbi_expires_field" .IX Subsection "session_store_dbi_expires_field" Return the configured expires field name. .SH "INTERNAL METHODS" .IX Header "INTERNAL METHODS" .SS "prepare" .IX Subsection "prepare" .SS "setup_actions" .IX Subsection "setup_actions" .SH "SEE ALSO" .IX Header "SEE ALSO" Catalyst, Catalyst::Plugin::Session, Catalyst::Plugin::Scheduler .SH "AUTHOR" .IX Header "AUTHOR" Andy Grundman, .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2005 \- 2009 the Catalyst::Plugin::Session::Store::DBI \*(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.