1CGI::Session::Driver::mUysseqrl(C3o)ntributed Perl DocumCeGnIt:a:tSieosnsion::Driver::mysql(3)
2
3
4
6 CGI::Session::Driver::mysql - CGI::Session driver for MySQL database
7
9 $s = new CGI::Session( "driver:mysql", $sid);
10 $s = new CGI::Session( "driver:mysql", $sid, { DataSource => 'dbi:mysql:test',
11 User => 'sherzodr',
12 Password => 'hello' });
13 $s = new CGI::Session( "driver:mysql", $sid, { Handle => $dbh } );
14
16 mysql stores session records in a MySQL table. For details see
17 CGI::Session::Driver::DBI, its parent class.
18
19 It's especially important for the MySQL driver that the session ID col‐
20 umn be defined as a primary key, or at least "unique", like this:
21
22 CREATE TABLE sessions (
23 id CHAR(32) NOT NULL PRIMARY KEY,
24 a_session TEXT NOT NULL
25 );
26
27 DRIVER ARGUMENTS
28
29 mysql driver supports all the arguments documented in CGI::Ses‐
30 sion::Driver::DBI. In addition, DataSource argument can optionally
31 leave leading "dbi:mysql:" string out:
32
33 $s = new CGI::Session( "driver:mysql", $sid, {DataSource=>'shopping_cart'});
34 # is the same as:
35 $s = new CGI::Session( "driver:mysql", $sid, {DataSource=>'dbi:mysql:shopping_cart'});
36
37 BACKWARDS COMPATIBILITY
38
39 For backwards compatibility, you can also set the table like this
40 before calling "new()". However, it is not recommended because it can
41 cause conflicts in a persistent environment.
42
43 $CGI::Session::MySQL::TABLE_NAME = 'my_sessions';
44
46 For support and licensing see CGI::Session.
47
48
49
50perl v5.8.8 2006-11-24 CGI::Session::Driver::mysql(3)