"My heart aches and a drowsy numbness pains my sense. as though of CGI::Session I had bummed..."
#!/usr/bin/perl -w # Import the modules use strict; use CGI::Session; use CGI::Pretty qw(:standard); use HTML::Template; use DBI; # various config parameters my $host = 'localhost'; my $db = 'dem.sqlite'; my $dbtype = 'SQLite'; #my $table = 'sessions'; my $dbuname = ''; my $dbpwd = ''; my $login_limit = 3; # create a new database connection my $dbh = DBI->connect("dbi:$dbtype:$db", '', '', {PrintError => 1, Ra +iseError => 1}); # The session is initialized or recalled. The session allows checking +whether # the user is logged in or not. my $cgi = new CGI; my $session = new CGI::Session("driver:$dbtype", $cgi, {Handle => $dbh +}); my $cookie = $cgi->cookie(CGISESSID => $session->id);
causes the following error --
Use of uninitialized value in join or string at 
/Library/Perl/5.8.1/darwin-thread-multi-2level/DBI.pm line 529 
during global destruction.
        (in cleanup) Can't connect(   HASH(0x80ca40)), no database 
driver specified and DBI_DSN env var not set at 
/Library/Perl/5.8.1/CGI/Session/SQLite.pm line 133
Line 133 in the relevant module is thusly
$self->{SQLite_dbh} = $args->{Handle} || DBI->connect( $args->{DataSource}, $args->{User} || undef, $args->{Password} || undef, { RaiseError=>1, PrintError=>1, AutoCommit=>1 } );
Needless to say, this darn thing was working in another incarnation. I have no idea where I have screwed it up, and now it croaks with the above error. As far as I can see, I am too passing it the Handle, so it shouldn't even bother trying to make another DBI connection.

Googling produces many instances of similar error, but with all kinds of different reasons, mainly relating to some typo or permissions error in creating the handle. Funny thing is, my $dbh is just fine as I have tested it with test queries and it works well.

Any insights will be much appreciated even if they show me up in a silly light. Learning experiences are always a step in the right direction.

Gracias.


In reply to problem with CGI::Session / DBI connection by punkish

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.