data/TWiki/CGISessionDriverMysqlDotPm.txt
author Colas Nahaboo <colas@nahaboo.net>
Sat, 26 Jan 2008 15:50:53 +0100
changeset 0 414e01d06fd5
permissions -rw-r--r--
RELEASE 4.2.0 freetown
colas@0
     1
---+ Package ==
colas@0
     2
*extends* <tt>CGI::Session::Driver::DBI </tt>
colas@0
     3
colas@0
     4
colas@0
     5
%TOC%
colas@0
     6
=head1 NAME
colas@0
     7
colas@0
     8
CGI::Session::Driver::mysql - CGI::Session driver for MySQL database
colas@0
     9
colas@0
    10
=head1 SYNOPSIS
colas@0
    11
colas@0
    12
    $s = new CGI::Session( "driver:mysql", $sid);
colas@0
    13
    $s = new CGI::Session( "driver:mysql", $sid, { DataSource  => 'dbi:mysql:test',
colas@0
    14
                                                   User        => 'sherzodr',
colas@0
    15
                                                   Password    => 'hello' });
colas@0
    16
    $s = new CGI::Session( "driver:mysql", $sid, { Handle => $dbh } );
colas@0
    17
colas@0
    18
=head1 DESCRIPTION
colas@0
    19
colas@0
    20
B<mysql> stores session records in a MySQL table. For details see L<CGI::Session::Driver::DBI|CGI::Session::Driver::DBI>, its parent class.
colas@0
    21
colas@0
    22
It's especially important for the MySQL driver that the session ID column be
colas@0
    23
defined as a primary key, or at least "unique", like this:
colas@0
    24
colas@0
    25
 CREATE TABLE sessions (
colas@0
    26
     id CHAR(32) NOT NULL PRIMARY KEY,
colas@0
    27
     a_session TEXT NOT NULL
colas@0
    28
  );
colas@0
    29
colas@0
    30
=head2 DRIVER ARGUMENTS
colas@0
    31
colas@0
    32
B<mysql> driver supports all the arguments documented in L<CGI::Session::Driver::DBI|CGI::Session::Driver::DBI>. In addition, I<DataSource> argument can optionally leave leading "dbi:mysql:" string out:
colas@0
    33
colas@0
    34
    $s = new CGI::Session( "driver:mysql", $sid, {DataSource=>'shopping_cart'});
colas@0
    35
    # is the same as:
colas@0
    36
    $s = new CGI::Session( "driver:mysql", $sid, {DataSource=>'dbi:mysql:shopping_cart'});
colas@0
    37
colas@0
    38
=head2 BACKWARDS COMPATIBILITY
colas@0
    39
colas@0
    40
For backwards compatibility, you can also set the table like this before calling C<new()>. However, it is not recommended because it can cause conflicts in a persistent environment. 
colas@0
    41
colas@0
    42
    $CGI::Session::MySQL::TABLE_NAME = 'my_sessions';
colas@0
    43
colas@0
    44
=head1 LICENSING
colas@0
    45
colas@0
    46
For support and licensing see L<CGI::Session|CGI::Session>.
colas@0
    47