1CGI::Session::Driver::mUysseqrl(C3o)ntributed Perl DocumCeGnIt:a:tSieosnsion::Driver::mysql(3)
2
3
4

NAME

6       CGI::Session::Driver::mysql - CGI::Session driver for MySQL database
7

SYNOPSIS

9           $s = CGI::Session->new( 'driver:mysql', $sid);
10           $s = CGI::Session->new( 'driver:mysql', $sid, { DataSource  => 'dbi:mysql:test',
11                                                          User        => 'sherzodr',
12                                                          Password    => 'hello' });
13           $s = CGI::Session->new( 'driver:mysql', $sid, { Handle => $dbh } );
14

DESCRIPTION

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
20       column 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       To use different column names, change the 'create table' statement, and
28       then simply do this:
29
30           $s = CGI::Session->new('driver:mysql', undef,
31           {
32               TableName=>'session',
33               IdColName=>'my_id',
34               DataColName=>'my_data',
35               DataSource=>'dbi:mysql:project',
36           });
37
38       or
39
40           $s = CGI::Session->new('driver:mysql', undef,
41           {
42               TableName=>'session',
43               IdColName=>'my_id',
44               DataColName=>'my_data',
45               Handle=>$dbh,
46           });
47
48   DRIVER ARGUMENTS
49       mysql driver supports all the arguments documented in
50       CGI::Session::Driver::DBI. In addition, DataSource argument can
51       optionally leave leading "dbi:mysql:" string out:
52
53           $s = CGI::Session->new( 'driver:mysql', $sid, {DataSource=>'shopping_cart'});
54           # is the same as:
55           $s = CGI::Session->new( 'driver:mysql', $sid, {DataSource=>'dbi:mysql:shopping_cart'});
56
57   BACKWARDS COMPATIBILITY
58       As of V 4.30, the global variable $CGI::Session::MySQL::TABLE_NAME
59       cannot be used to set the session table's name.
60
61       This is due to changes in CGI::Session::Driver's new() method, which
62       now allows the table's name to be changed (as well as allowing both the
63       'id' column name and the 'a_session' column name to be changed).
64
65       See the documentation for CGI::Session::Driver::DBI for details.
66
67       In particular, the new syntax for new() applies to all database
68       drivers, whereas the old - and bad - global variable method only
69       applied to MySQL.
70
71       Alternately, call $session -> table_name('new_name') just after
72       creating the session object if you wish to change the session table's
73       name.
74

LICENSING

76       For support and licensing see CGI::Session.
77
78
79
80perl v5.38.0                      2023-07-20    CGI::Session::Driver::mysql(3)
Impressum