Re: [Cgi-session-user] a bug or two related to _load_pluggables? (was: Problem With CGI::Session v.
Brought to you by:
sherzodr
From: Mark S. <ma...@su...> - 2007-05-08 12:10:34
|
> I just wanted to create a new session and got some errors. My code is > the following: > > use strict; > use Env; > use File::Basename; > use DBI; > use lib dirname(__FILE__) . ''; > use CGI; > use CGI::Carp "fatalsToBrowser"; > use CGI::Session; > use CGI::Session::ID::md5; > use Digest::MD5 qw(md5 md5_hex md5_base64); > > my $sid = md5($ENV{UNIQUE_ID}); > my $cgi = new CGI; > > #print "Content-Type: text/html\n\n"; > print $cgi->start_html( > > -title => 'Switch.cgi', > -author => 'Ulr...@qi...' > ); > #print $sid; > my $session = new CGI::Session(undef, undef, > {Directory=>'/tmp/session'}) or die CGI::Session->errstr; > $sid = $session->id(); > print $sid; > > The error-message is the folowing: > > session.cgi: Use of uninitialized value in concatenation (.) or string > at /opt/webserver/software/perl/lib/5.6.1/CGI/Session.pm line 128. > Can't locate object method "generate_id" via package > "CGI::Session::ID::" at > /opt/webserver/software/perl/lib/5.6.1/CGI/Session.pm line 74. > > I'm using Perl-Version 5.6.1 > CGI.pm has the version 3.05 > And Session.pm has the version 4.20 Ulrich, First, you can remove this line: It shouldn't be needed: > use CGI::Session::ID::md5; I see what looks like a bug (or two), but I don't understand why it wouldn't affect more people. First bug: - 'sub _id_generator' uses a variable without checking to see if it exists first. If it did, it could have returned a more friendly error message than the one you got. (This is not causing your problem, but is related). Second bug: - 'sub _load_pluggables' takes care of loading a default ID generator, and putting the result in $self->{_DSN}{id}, which doesn't seem to be happening for you. Look at line 798 in CGI/Session.pm: $dsn->{ $plug } = $mod_name = $1; By using Data::Dumper and 'warn', inspect the values of '$dsn->{$plug}' and '$mod_name' before and after that line. By continuing to debug in 'sub _load_pluggables', I think you'll find the issue. Maybe it's something related to Perl 5.6.1 being older? Did the whole test suite pass for you OK? If you need an immediate result, the workaround seems to be explicitly name the serializer, driver and ID generator you want in the DSN. Mark |