3 package Catalyst::Plugin::Session::Store;
16 Catalyst::Plugin::Session::Store - Base class for session storage
21 package Catalyst::Plugin::Session::Store::MyBackend;
22 use base qw/Catalyst::Plugin::Session::Store/;
26 This class doesn't actually provide any functionality, but when the
27 C<Catalyst::Plugin::Session> module sets up it will check to see that
28 C<< YourApp->isa("Catalyst::Plugin::Session::Store") >>.
30 When you write a session storage plugin you should subclass this module this
33 =head1 WRITING STORE PLUGINS
35 All session storage plugins need to adhere to the following interface
36 specification to work correctly:
38 =head2 Required Methods
42 =item get_session_data $sid
44 Retrieve a session from storage, whose ID is the first parameter.
46 Should return a hash reference.
48 =item store_session_data $sid, $hashref
50 Store a session whose ID is the first parameter and data is the second
53 The second parameter is an hash reference, that should normally be serialized
54 (and later deserialized by C<get_session_data>).
56 =item delete_session_data $sid
58 Delete the session whose ID is the first parameter.
60 =item delete_expired_sessions
62 This method is not called by any code at present, but may be called in the
63 future, as part of a catalyst specific maintenance script.
65 If you are wrapping around a backend which manages it's own auto expiry you can
66 just give this method an empty body.
72 All errors should be thrown using L<Catalyst::Exception>. Return values are not
73 checked at all, and are assumed to be OK.
75 =head2 Auto-Expirey on the Backend
77 Storage plugins are encouraged to use C<< $c->config->{session}{expires} >> and
78 the C<__expires> key in the session data hash reference to auto expire data on
81 If the backend chooses not to do so, L<Catalyst::Plugin::Session> will detect
82 expired sessions as they are retrieved and delete them if necessary.
84 Note that session storages that use this approach may leak disk space, since
85 nothing will actively delete expired session. The C<delete_expired_sessions>
86 method is there so that regularly scheduled maintenance scripts can give your
87 backend the opportunity to clean up.