title: Perl CGI::Session using CGI::Session::Driver::mysql
body: <p>I'm having an issue with storing sessions in a MySQL database using CGI::Session.</p>
  
  <p>Here is a snippet</p>
  
  <pre><code>#!/usr/bin/perl
  
  use CGI;
  use CGI::Session;
  use CGI::Session::Driver::mysql;
  use DBI;
  use DBD::mysql;
  use Net::LDAPS;
  
  require '../include/include.pl';
  
  $LDAP_SERVER = 'my.test.ldap.example.com';
  $LDAP_SSL_PORT = '636';
  $LDAP_BASE = 'ou=users,dc=example,dc=com';
  
  $ldap = Net::LDAPS-&gt;new($LDAP_SERVER, port=&gt; $LDAP_SSL_PORT)
      or die "Unable to create LDAP object because: $! \n";
  
  $dbh = DBI-&gt;connect("DBI:mysql:host=$db_host;database=$db_name",$db_user,$db_pswd)
      or die "Unable to connect to database: \"$DBI::errstr\" $! \n";
  
  $q = CGI-&gt;new;
  
  $usr = $q-&gt;param('usr') || undef;
  $userDN = "uid=$usr,$LDAP_BASE";
  
  if($usr) {
      $pwd = $q-&gt;param('pwd');
      $ldapMsg = $ldap-&gt;bind($userDN, password=&gt;$pwd);
      $result = $ldap-&gt;code;
  
      if ($result == 0) {
          $session = CGI::Session-&gt;new('driver:mysql', undef, 
                       {  TableName=&gt;'car_sessions',
                          IdColName=&gt;'id',
                          DataColName=&gt;'a_session',
                          Handle=&gt;$dbh})
              or die "Unable to create session because: $!";
  
          $session-&gt;expire('+1h');
          $session-&gt;param(-name=&gt;'car_login', -value=&gt;$usr);
          $sess_cookie = $q-&gt;cookie(-name=&gt;'CGISESSID', -value=&gt;$session-&gt;id, -expires=&gt;'+1h', -path=&gt;'/hr_car/');
          $login_cookie = $q-&gt;cookie(-name=&gt;'car_login', -value=&gt;$usr, -expires=&gt;'+1h', -path=&gt;'/hr_car/');
          print $q-&gt;header(-cookie=&gt;[$sess_cookie, $login_cookie], -location=&gt;'manage.cgi');
      }
  </code></pre>
  
  <p>LDAP is binding correctly, and the cookies are being set correctly, but NOTHING is showing up in my sessions table!</p>
  
  <p>What could I be doing wrong??</p>