Hi everybody,

I wrote this little cron script that deletes any expired sessions that happen to still be on disk.

I'm using CGI::Session to handle my sessions and everything seems to be going well except for this error I keep getting when running the cron script.
disconnect invalidates 1 active statement handle DBI::db=HASH(0x8320754)->disconnect invalidates 1 active statement han +dle (either destroy statement handles or call finish on them before d +isconnecting)
I have no clue what I'm doing wrong...and can only assume its something to do with the new 4.20 CGI::Session module.

The following uses the new load method to check for expired sessions:
use DBI; my $dbh = DBI->connect($location, $user, $ba_pass, { RaiseError => + 1, AutoCommit => 1}) or die "Couldn't connect to database: " . $DBI: +:errstr; eval { my $sth= $dbh->prepare("SELECT id FROM sessions"); my $id; $sth->execute; $sth->bind_columns(undef, \$id); my $f = 0; while ($sth->fetch) { $f++; if ($f == 1) { require CGI::Session; import CGI::Session; $CGI::Session::IP_MATCH = 0; } my $session = CGI::Session->load("driver:MySQL", + $id, {Handle=>$dbh}); if ($session->is_expired) { $session->delete(); $session->close(); } } $dbh->disconnect; }; if ($@) { print $@; $dbh->disconnect; }
I did also add $sth->finish before calling disconnect, but it still gives me the same error. So its not the $sth handle...also I do know theres no need to call $sth->finish if DBI knows when the fetching suppose to stop. So my question is, whats causing this error? How can I further debug what handle is active and not being finished?

UPDATE:
figured out how to check for active handles by using ActiveKids.

Thanks,
perleager

In reply to CGI::Session disconnect invalidates 1 active statement handle by perleager

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.