NAME
CGI::Session::MySQL - MySQL driver for CGI::Session
SYNOPSIS
use CGI::Session;
$session = new CGI::Session("driver:MySQL", undef, {Handle=>$dbh});
For more examples, consult CGI::Session manual
DESCRIPTION
CGI::Session::MySQL is a CGI::Session driver to store session data in MySQL table. To write your own drivers for CGI::Session refere CGI::Session manual.
STORAGE
To store session data in MySQL database, you first need to create a suitable table for it with the following command:
CREATE TABLE sessions (
id CHAR(32) NOT NULL,
a_session TEXT NOT NULL
);
You can also add any number of additional columns to the table, but the above "id" and "a_session" are required.
If you want to store the session data in other table than "sessions", you need to defined TableName option:
use CGI::Session;
$session = new CGI::Session("driver:MySQL", undef, {Handle=>$dbh, TableName=>"my_sessions"});
DRIVER OPTIONS
Following driver options are supported:
- Handle
-
Database handle returned from DBI->connect(...) to be used to access session table.
If database handle is not available, the following options can be given to CGI::Session::MySQL to establish connection.
- DataSource
-
DSN passed as the first argument to DBI->connect(...):
- User
-
User to connect to DataSource as. Passed as the second argument to DBI->connect();
- Password
-
Password used by the user to access the DataSource
EXAMPLES
$session = new CGI::Session("dr:MySQL", undef, {Handle=>$dbh});
$session = new CGI::Session("dr:MySQL", undef, {Handle=>$dbh, TableName=>"my_sessions"});
$session = new CGI::Session("dr:MySQL", undef, {DataSource=>"dbi:mysql:temp",
User=>"cgisess",
Password => "marley01"});
COPYRIGHT
Copyright (C) 2001, 2002 Sherzod Ruzmetov. All rights reserved.
This library is free software and can be modified and distributed under the same terms as Perl itself.
AUTHOR
Sherzod Ruzmetov <sherzodr@cpan.org>. All the bug reports should be sent to the author to sherzodr@cpan.org>
SEE ALSO
CGI::Session - CGI::Session manual
CGI::Session::Tutorial - extended CGI::Session manual
CGI::Session::CookBook - practical solutions for real life problems
RFC 2965 - "HTTP State Management Mechanism" found at ftp://ftp.isi.edu/in-notes/rfc2965.txt
CGI - standard CGI library
Apache::Session - another fine alternative to CGI::Session