On Thu, Jan 26, 2006 at 01:30:04PM -0500, Guest via RT wrote:
Show quoted text>
> I wrote a script ages ago (just checked the source) that handled
> sessions fine w/o using ->flush() or ->close() anywhere. It was for the
> debian woody release (eaisly mid 2004).
>
> I've tested this script on a few machines (omni, saturn). The use of
> lastpid was an attempt to see if the session was saving anything...
> (releases me from poking mysql on yet another terminal) When I replace
> END with if (0) { ... } it stops saving session data.
Thanks for the report. I believe there is at least one other report in
the bug queue already reporting the same thing.
A patch would be welcome.
I know it can be frustrating-- I ran into a related variation of it
myself recently. (Except in my variation, I had created the problem
myself!)
Mark
Show quoted text> Source snippet:
>
> #!/usr/bin/perl -w -I/home/staff/include
> ###########################################################################
> # supaplex 2006-01-11
>
> use strict;
> use DBH; # internal module. works great on all our other DBI apps.
> use CGI;
> use CGI::Session;
> use Data::Dumper;
> use vars qw($session $dbh);
>
> my $cgi=new CGI;
> my $session;
> my $dbh = DBH->new('voip') or
> reportErrors("Cannot connect to voip database");
> my $sid=$cgi->param("sid")||undef;
> eval {
> $session=new CGI::Session("driver:MySQL",$sid,{Handle => $dbh});
> } or reportErrors("Session INIT error",$@);
> END {
> print STDERR "Commiting session data... ";
> $session->flush();
> print STDERR "Done.\n";
> }
> $sid=$session->id();
> reportErrors("session failed to create or obtain an id")
> unless($sid);
> my $lastpid=$session->param("lastpid");
> $session->param("lastpid",$$);
>
> my $SCRIPT=$ENV{"SCRIPT_NAME"};
>
> $session->param("step",512);
> my $user = $cgi->param("search")||'';
> my $error =$cgi->param("error")||'';
> $error = '<p style="font-size: 2em; color: #f00;" class="error">'
> .$error."</p>\n";
> print $session->header();
> print qq(<form action="$SCRIPT" method="post">
> <input type="text" name="search" value="$user" />
> <input type="submit" name="submit" value="Search" />
> <input type="hidden" name="sid" value="$sid" />
> </form>
> SID: $sid<br />
> Lastpid: [$lastpid]<br />
> Pid: [$$]<br />
>
> \$session->param("lastpid")=).$session->param("lastpid").qq(<br />
> \$session->id()=).$session->id().qq(<br />
> );
>
>
> sub reportErrors
> {
> my ($j,$k,$l) = caller;
> my $msg = shift;
> if (defined $session) {
> print $session->header();
> } else {
> print "Content-type: text/html\n\n";
> }
> print $msg." [$l]";
> print STDERR $_,"\n" foreach(@_);
> print STDERR $DBI::errstr,"\n" if($DBI::errstr);
> exit 1;
> }
>
> ##### omni:
>
> FreeBSD omni 5.4-RELEASE FreeBSD 5.4-RELEASE #0: Sun May 8 10:21:06 UTC
> 2005 root@harlow.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
>
> This is a fairly recent fresh install of FreeBSD 5.4.
>
> This is perl, v5.8.7 built for i386-freebsd-64int
> (with 1 registered patch, see perl -V for more detail)
>
> omni behaves about the same, but also supplies these warnings:
> Commiting session data... Done.
> (in cleanup) Can't connect to data source , no database driver
> specified and DBI_DSN env var not set at
> /usr/local/lib/perl5/site_perl/5.8.7/CGI/Session/MySQL.pm line 131
>
> Not all that important, because the data *is* recorded...
>
> ##### saturn:
>
> FreeBSD saturn 4.9-PRERELEASE FreeBSD 4.9-PRERELEASE #0: Tue May 18
> 00:58:36 MDT 2004 root@saturn:/usr/src/sys/compile/AROS-SMP i386
>
> This is perl, version 5.005_03 built for i386-freebsd
>
> saturn behaves about the same, but also supplies these warnings:
> Commiting session data... Done.
> Use of uninitialized value during global destruction.
> Use of uninitialized value during global destruction.
> Use of uninitialized value during global destruction.
>
--
. . . . . . . . . . . . . . . . . . . . . . . . . . .
Mark Stosberg Principal Developer
mark@summersault.com Summersault, LLC
765-939-9301 ext 202 database driven websites
. . . . .
http://www.summersault.com/ . . . . . . . .