1Catalyst::Plugin::SessiUosne:r:SCtoonrter:i:bDuBtIeCdC(a3Pt)earllysDto:c:uPmleungtiant:i:oSnession::Store::DBIC(3)
2
3
4

NAME

6       Catalyst::Plugin::Session::Store::DBIC - Store your sessions via
7       DBIx::Class
8

SYNOPSIS

10           # Create a table in your database for sessions
11           CREATE TABLE sessions (
12               id           CHAR(72) PRIMARY KEY,
13               session_data TEXT,
14               expires      INTEGER
15           );
16
17           # Create the corresponding table class
18           package MyApp::Schema::Session;
19
20           use base qw/DBIx::Class/;
21
22           __PACKAGE__->load_components(qw/Core/);
23           __PACKAGE__->table('sessions');
24           __PACKAGE__->add_columns(qw/id session_data expires/);
25           __PACKAGE__->set_primary_key('id');
26
27           1;
28
29           # In your application
30           use Catalyst qw/Session Session::Store::DBIC Session::State::Cookie/;
31
32           __PACKAGE__->config(
33               # ... other items ...
34               'Plugin::Session' => {
35                   dbic_class => 'DBIC::Session',  # Assuming MyApp::Model::DBIC
36                   expires    => 3600,
37               },
38           );
39
40           # Later, in a controller action
41           $c->session->{foo} = 'bar';
42

DESCRIPTION

44       This Catalyst::Plugin::Session storage module saves session data in
45       your database via DBIx::Class.  It's actually just a wrapper around
46       Catalyst::Plugin::Session::Store::Delegate; if you need complete
47       control over how your sessions are stored, you probably want to use
48       that instead.
49

METHODS

51   setup_finished
52       Hook into the configured session class.
53
54   session_store_dbic_class
55       Return the DBIx::Class class name to be passed to "$c->model".
56       Defaults to "DBIC::Session".
57
58   session_store_dbic_id_field
59       Return the configured ID field name.  Defaults to "id".
60
61   session_store_dbic_data_field
62       Return the configured data field name.  Defaults to "session_data".
63
64   session_store_dbic_expires_field
65       Return the configured expires field name.  Defaults to "expires".
66
67   session_store_model
68       Return the model used to find a session.
69
70   get_session_store_delegate
71       Load the row corresponding to the specified session ID.  If none is
72       found, one is automatically created.
73
74   session_store_delegate_key_to_accessor
75       Match the specified key and operation to the session ID and field name.
76
77   delete_session_data
78       Delete the specified session from the backend store.
79
80   delete_expired_sessions
81       Delete all expired sessions.
82

CONFIGURATION

84       The following parameters should be placed in your application
85       configuration under the "Plugin::Session" key.
86
87   dbic_class
88       (Required) The name of the DBIx::Class that represents a session in the
89       database.  It is recommended that you provide only the part after
90       "MyApp::Model", e.g. "DBIC::Session".
91
92       If you are using Catalyst::Model::DBIC::Schema, the following layout is
93       recommended:
94
95       •   "MyApp::Schema" - your DBIx::Class::Schema class
96
97       •   "MyApp::Schema::Session" - your session table class
98
99       •   "MyApp::Model::DBIC" - your Catalyst::Model::DBIC::Schema class
100
101       This module will then use "$c->model" to access the appropriate result
102       source from the composed schema matching the "dbic_class" name.
103
104       For more information, please see Catalyst::Model::DBIC::Schema.
105
106   expires
107       Number of seconds for which sessions are active.
108
109       Note that no automatic cleanup is done on your session data.  To delete
110       expired sessions, you can use the "delete_expired_sessions" method with
111       Catalyst::Plugin::Scheduler.
112
113   id_field
114       The name of the field on your sessions table which stores the session
115       ID.  Defaults to "id".
116
117   data_field
118       The name of the field on your sessions table which stores session data.
119       Defaults to "session_data" for compatibility with
120       Catalyst::Plugin::Session::Store::DBI.
121
122   expires_field
123       The name of the field on your sessions table which stores the
124       expiration time of the session.  Defaults to "expires".
125

SCHEMA

127       Your sessions table should contain the following columns:
128
129           id           CHAR(72) PRIMARY KEY
130           session_data TEXT
131           expires      INTEGER
132
133       The "id" column should probably be 72 characters.  It needs to handle
134       the longest string that can be returned by "generate_session_id" in
135       Catalyst::Plugin::Session, plus another eight characters for internal
136       use.  This is less than 72 characters when SHA-1 or MD5 is used, but
137       SHA-256 will need all 72 characters.
138
139       The "session_data" column should be a long text field.  Session data is
140       encoded using MIME::Base64 before being stored in the database.
141
142       Note that MySQL "TEXT" fields only store 64 kB, so if your session data
143       will exceed that size you'll want to use "MEDIUMTEXT", "MEDIUMBLOB", or
144       larger. If you configure your DBIx::Class::ResultSource to include the
145       size of the column, you will receive warnings for this problem:
146
147           This session requires 1180 bytes of storage, but your database
148           column 'session_data' can only store 200 bytes. Storing this
149           session may not be reliable; increase the size of your data field
150
151       See "add_columns" in DBIx::Class::ResultSource for more information.
152
153       The "expires" column stores the future expiration time of the session.
154       This may be null for per-user and flash sessions.
155
156       Note that you can change the column names using the "id_field",
157       "data_field", and "expires_field" configuration parameters.  However,
158       the column types must match the above.
159

AUTHOR

161       Daniel Westermann-Clark <danieltwc@cpan.org>
162

ACKNOWLEDGMENTS

164       •   Andy Grundman, for Catalyst::Plugin::Session::Store::DBI
165
166       •   David Kamholz, for most of the testing code (from
167                   Catalyst::Plugin::Authentication::Store::DBIC)
168
169       •   Yuval Kogman, for assistance in converting to
170                   Catalyst::Plugin::Session::Store::Delegate
171
172       •   Jay Hannah, for tests and warning when session size
173                   exceeds DBIx::Class storage size.
174
176       Copyright (c) 2006 - 2009 the Catalyst::Plugin::Session::Store::DBIC
177       "AUTHOR" as listed above.
178
179       This program is free software; you can redistribute it and/or modify it
180       under the same terms as Perl itself.
181
182
183
184perl v5.36.0                      2023C-a0t1a-l2y0st::Plugin::Session::Store::DBIC(3)
Impressum