{
    "mode": "perldoc",
    "parameter": "CGI::Session::Driver::DBI",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/CGI%3A%3ASession%3A%3ADriver%3A%3ADBI/json",
    "generated": "2026-06-14T05:35:25Z",
    "synopsis": "require CGI::Session::Driver::DBI;\n@ISA = qw( CGI::Session::Driver::DBI );",
    "sections": {
        "NAME": {
            "content": "CGI::Session::Driver::DBI - Base class for native DBI-related CGI::Session drivers\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "require CGI::Session::Driver::DBI;\n@ISA = qw( CGI::Session::Driver::DBI );\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "In most cases you can create a new DBI-driven CGI::Session driver by simply creating an empty\ndriver file that inherits from CGI::Session::Driver::DBI. That's exactly what sqlite does. The\nonly reason why this class doesn't suit for a valid driver is its name isn't in lowercase. I'm\nserious!\n\nNOTES\nCGI::Session::Driver::DBI defines init() method, which makes DBI handle available for drivers in\n*Handle* - object attribute regardless of what \"\\%dsnargs\" were used in creating session\nobject. Should your driver require non-standard initialization you have to re-define init()\nmethod in your .pm file, but make sure to set 'Handle' - object attribute to database handle\n(returned by DBI->connect(...)) if you wish to inherit any of the methods from\nCGI::Session::Driver::DBI.\n",
            "subsections": []
        },
        "STORAGE": {
            "content": "Before you can use any DBI-based session drivers you need to make sure compatible database table\nis created for CGI::Session to work with. Following command will produce minimal requirements in\nmost SQL databases:\n\nCREATE TABLE sessions (\nid CHAR(32) NOT NULL PRIMARY KEY,\nasession TEXT NOT NULL\n);\n\nYour session table can define additional columns, but the above two are required. Name of the\nsession table is expected to be *sessions* by default. You may use a different name if you wish.\nTo do this you have to pass *TableName* as part of your \" \\%dsnargs \":\n\n$s = CGI::Session->new('driver:sqlite', undef, {TableName=>'mysessions'});\n$s = CGI::Session->new('driver:mysql', undef,\n{\nTableName=>'mysessions',\nDataSource=>'dbi:mysql:shoppingcart'.\n});\n\nTo use different column names, change the 'create table' statement, and then simply do this:\n\n$s = CGI::Session->new('driver:pg', undef,\n{\nTableName=>'session',\nIdColName=>'myid',\nDataColName=>'mydata',\nDataSource=>'dbi:pg:dbname=project',\n});\n\nor\n\n$s = CGI::Session->new('driver:pg', undef,\n{\nTableName=>'session',\nIdColName=>'myid',\nDataColName=>'mydata',\nHandle=>$dbh,\n});\n",
            "subsections": []
        },
        "DRIVER ARGUMENTS": {
            "content": "Following driver arguments are supported:\n\nDataSource\nFirst argument to be passed to DBI->connect(). If the driver makes the database connection\nitself, it will also explicitly disconnect from the database when the driver object is\nDESTROYed.\n\nUser\nUser privileged to connect to the database defined in \"DataSource\".\n\nPassword\nPassword of the *User* privileged to connect to the database defined in \"DataSource\"\n\nHandle\nAn existing DBI database handle object. The handle can be created on demand by providing a\ncode reference as a argument, such as \"<sub{DBI-\"connect}>>. This way, the database\nconnection is only created if it actually needed. This can be useful when combined with a\nframework plugin like CGI::Application::Plugin::Session, which creates a CGI::Session object\non demand as well.\n\n\"Handle\" will override all the above arguments, if any present.\n\nTableName\nName of the table session data will be stored in.\n",
            "subsections": []
        },
        "LICENSING": {
            "content": "For support and licensing information see CGI::Session\n",
            "subsections": []
        }
    },
    "summary": "CGI::Session::Driver::DBI - Base class for native DBI-related CGI::Session drivers",
    "flags": [],
    "examples": [],
    "see_also": []
}