{
    "mode": "perldoc",
    "parameter": "CGI::Session::Driver::mysql",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/CGI%3A%3ASession%3A%3ADriver%3A%3Amysql/json",
    "generated": "2026-06-13T06:41:40Z",
    "synopsis": "$s = CGI::Session->new( 'driver:mysql', $sid);\n$s = CGI::Session->new( 'driver:mysql', $sid, { DataSource  => 'dbi:mysql:test',\nUser        => 'sherzodr',\nPassword    => 'hello' });\n$s = CGI::Session->new( 'driver:mysql', $sid, { Handle => $dbh } );",
    "sections": {
        "NAME": {
            "content": "CGI::Session::Driver::mysql - CGI::Session driver for MySQL database\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "$s = CGI::Session->new( 'driver:mysql', $sid);\n$s = CGI::Session->new( 'driver:mysql', $sid, { DataSource  => 'dbi:mysql:test',\nUser        => 'sherzodr',\nPassword    => 'hello' });\n$s = CGI::Session->new( 'driver:mysql', $sid, { Handle => $dbh } );\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "mysql stores session records in a MySQL table. For details see CGI::Session::Driver::DBI, its\nparent class.\n\nIt's especially important for the MySQL driver that the session ID column be defined as a\nprimary key, or at least \"unique\", like this:\n\nCREATE TABLE sessions (\nid CHAR(32) NOT NULL PRIMARY KEY,\nasession TEXT NOT NULL\n);\n\nTo use different column names, change the 'create table' statement, and then simply do this:\n\n$s = CGI::Session->new('driver:mysql', undef,\n{\nTableName=>'session',\nIdColName=>'myid',\nDataColName=>'mydata',\nDataSource=>'dbi:mysql:project',\n});\n\nor\n\n$s = CGI::Session->new('driver:mysql', undef,\n{\nTableName=>'session',\nIdColName=>'myid',\nDataColName=>'mydata',\nHandle=>$dbh,\n});\n\nDRIVER ARGUMENTS\nmysql driver supports all the arguments documented in CGI::Session::Driver::DBI. In addition,\n*DataSource* argument can optionally leave leading \"dbi:mysql:\" string out:\n\n$s = CGI::Session->new( 'driver:mysql', $sid, {DataSource=>'shoppingcart'});\n# is the same as:\n$s = CGI::Session->new( 'driver:mysql', $sid, {DataSource=>'dbi:mysql:shoppingcart'});\n\nBACKWARDS COMPATIBILITY\nAs of V 4.30, the global variable $CGI::Session::MySQL::TABLENAME cannot be used to set the\nsession table's name.\n\nThis is due to changes in CGI::Session::Driver's new() method, which now allows the table's name\nto be changed (as well as allowing both the 'id' column name and the 'asession' column name to\nbe changed).\n\nSee the documentation for CGI::Session::Driver::DBI for details.\n\nIn particular, the new syntax for \"new()\" applies to all database drivers, whereas the old - and\nbad - global variable method only applied to MySQL.\n\nAlternately, call $session -> tablename('newname') just after creating the session object if\nyou wish to change the session table's name.\n",
            "subsections": []
        },
        "LICENSING": {
            "content": "For support and licensing see CGI::Session.\n",
            "subsections": []
        }
    },
    "summary": "CGI::Session::Driver::mysql - CGI::Session driver for MySQL database",
    "flags": [],
    "examples": [],
    "see_also": []
}