1Plack::Session::Store::UDsBeIr(3Cpomn)tributed Perl DocuPmleanctka:t:iSoenssion::Store::DBI(3pm)
2
3
4
6 Plack::Session::Store::DBI - DBI-based session store
7
9 use Plack::Builder;
10 use Plack::Middleware::Session;
11 use Plack::Session::Store::DBI;
12
13 my $app = sub {
14 return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello Foo' ] ];
15 };
16
17 builder {
18 enable 'Session',
19 store => Plack::Session::Store::DBI->new(
20 dbh => DBI->connect( @connect_args )
21 );
22 $app;
23 };
24
25 # set get_dbh callback for ondemand
26
27 builder {
28 enable 'Session',
29 store => Plack::Session::Store::DBI->new(
30 get_dbh => sub { DBI->connect( @connect_args ) }
31 );
32 $app;
33 };
34
35 # with custom serializer/deserializer
36
37 builder {
38 enable 'Session',
39 store => Plack::Session::Store::DBI->new(
40 dbh => DBI->connect( @connect_args )
41 # YAML takes its args in the opposite order
42 serializer => sub { YAML::DumpFile( reverse @_ ) },
43 deserializer => sub { YAML::LoadFile( @_ ) },
44 );
45 $app;
46 };
47
48
49 # use custom session table name
50
51 builder {
52 enable 'Session',
53 store => Plack::Session::Store::DBI->new(
54 dbh => DBI->connect( @connect_args ),
55 table_name => 'my_session_table',
56 );
57 $app;
58 };
59
61 This implements a DBI based storage for session data. By default it
62 will use Storable and MIME::Base64 to serialize and deserialize the
63 data, but this can be configured easily.
64
65 This is a subclass of Plack::Session::Store and implements its full
66 interface.
67
69 Your session table must have at least the following schema structure:
70
71 CREATE TABLE sessions (
72 id CHAR(72) PRIMARY KEY,
73 session_data TEXT
74 );
75
76 Note that MySQL TEXT fields only store 64KB, so if your session data
77 will exceed that size you'll want to move to MEDIUMTEXT, MEDIUMBLOB, or
78 larger.
79
81 Many aspects of this module were partially based upon
82 Catalyst::Plugin::Session::Store::DBI
83
84 Daisuke Maki
85
87 Copyright 2009, 2010 Daisuke Maki "<daisuke@endeworks.jp>"
88
89 This library is free software; you can redistribute it and/or modify it
90 under the same terms as Perl itself.
91
92
93
94perl v5.32.1 2021-01-27 Plack::Session::Store::DBI(3pm)