1CGI::Session::Driver::DUBsIe(r3)Contributed Perl DocumenCtGaIt:i:oSnession::Driver::DBI(3)
2
3
4

NAME

6       CGI::Session::Driver::DBI - Base class for native DBI-related CGI::Ses‐
7       sion drivers
8

SYNOPSIS

10           require CGI::Session::Driver::DBI;
11           @ISA = qw( CGI::Session::Driver::DBI );
12

DESCRIPTION

14       In most cases you can create a new DBI-driven CGI::Session driver by
15       simply creating an empty driver file that inherits from CGI::Ses‐
16       sion::Driver::DBI. That's exactly what sqlite does. The only reason why
17       this class doesn't suit for a valid driver is its name isn't in lower‐
18       case. I'm serious!
19
20       NOTES
21
22       CGI::Session::Driver::DBI defines init() method, which makes DBI handle
23       available for drivers in Handle - object attribute regardless of what
24       "\%dsn_args" were used in creating session object. Should your driver
25       require non-standard initialization you have to re-define init() method
26       in your .pm file, but make sure to set 'Handle' - object attribute to
27       database handle (returned by DBI->connect(...)) if you wish to inherit
28       any of the methods from CGI::Session::Driver::DBI.
29

STORAGE

31       Before you can use any DBI-based session drivers you need to make sure
32       compatible database table is created for CGI::Session to work with.
33       Following command will produce minimal requirements in most SQL data‐
34       bases:
35
36           CREATE TABLE sessions (
37               id CHAR(32) NOT NULL PRIMARY KEY,
38               a_session TEXT NOT NULL
39           );
40
41       Your session table can define additional columns, but the above two are
42       required. Name of the session table is expected to be sessions by
43       default. You may use a different name if you wish. To do this you have
44       to pass TableName as part of your " \%dsn_args ":
45
46           $s = new CGI::Session("driver:sqlite", undef, {TableName=>'my_sessions'});
47           $s = new CGI::Session("driver:mysql", undef, {
48                                               TableName=>'my_sessions',
49                                               DataSource=>'dbi:mysql:shopping_cart'});
50

DRIVER ARGUMENTS

52       Following driver arguments are supported:
53
54       DataSource
55           First argument to be passed to DBI->connect(). If the driver makes
56           the database connection itself, it will also explicitly disconnect
57           from the database when the driver object is DESTROYed.
58
59       User
60           User privileged to connect to the database defined in "DataSource".
61
62       Password
63           Password of the User privileged to connect to the database defined
64           in "DataSource"
65
66       Handle
67           An existing DBI database handle object. The handle can be created
68           on demand by providing a code reference as a argument, such as
69           "<sub{DBI-"connect}>>.  This way, the database connection is only
70           created if it actually needed. This can be useful when combined
71           with a framework plugin like CGI::Application::Plugin::Session,
72           which creates a CGI::Session object on demand as well.
73
74           "Handle" will override all the above arguments, if any present.
75
76       TableName
77           Name of the table session data will be stored in.
78

LICENSING

80       For support and licensing information see CGI::Session
81
82
83
84perl v5.8.8                       2006-11-24      CGI::Session::Driver::DBI(3)
Impressum