JESii has asked for the wisdom of the Perl Monks concerning the following question:

I'm using CGI::Application and just added CGI::Session for session handling. Now I get the error message:

Error executing run mode 'login_process': Can't locate auto/CGI/Session/File/expired.al in @INC.

@INC contains:

/usr/local/lib/perl5/5.8.2/i386-freebsd
/usr/local/lib/perl5/5.8.2
/usr/local/lib/perl5/site_perl/5.8.2/i386-freebsd
/usr/local/lib/perl5/site_perl/5.8.2
/usr/local/lib/perl5/site_perl/5.8.0
/usr/local/lib/perl5/site_perl

The relevant code snippets follow: the cgiapp_prerun method where I get the session and check to see if the user is logged in. If they are not logged in, then I divert them to the 'login_form', and then the error is generated when I try to switch modes.

### Pre-runmode method sub cgiapp_prerun { my $self = shift; my $next_mode = shift; my $q = $self->query(); $self->_get_session(); ### If a login/help runmode, then you're finished... if ($next_mode =~ m/^help_/ || $next_mode =~ m/^login_/ || $next_mode =~ m/^splash_screen_/ ) { return; } ### All other runmodes require that you be logged in... unless ($Session->param("_Is-Logged_In")) { ### Save current runmode and passed parameters so that we can +re-invoke it after ### the user gets logged in... $Session->save_param($q); $Session->param("Logged-In-Runmode", $next_mode); $self->prerun_mode("login_form"); } return; } ### Get a session for this invocation sub _get_session { my $self = shift; my $q = $self->query(); $Session = new CGI::Session(undef, $q, {Directory=>"/tmp"}), unles +s ($Session); $SessionID = $Session->id(); if ($Session->is_new() ) { $Session->expire('+1y'); my $cookie = $q->cookie(-name => "CGISESSID", -value => $SessionID, -expires => '+1y'); $self->header_props(-cookie => $cookie); } }

When I do a find, the "expired.al" file is not found. However, find does locate the following files:


/usr/local/lib/perl5/site_perl/5.8.2/auto/CGI/Session/expire.al
/usr/local/lib/perl5/site_perl/5.8.2/auto/CGI/Session/expires.al

I've checked CPAN (perl -MCPAN ...) and I have the latest version (3.95). Just to make sure, I downloaded it again and forced an install.

Curiously, when I ask the CPAN module to check for reinstall recommendations, the CGI::Session module isn't listed ("72 installed modules have no parseable version number"), but when I look at the CGI::Session code, there's a version number there:

use vars qw($VERSION $REVISION $errstr $IP_MATCH $NAME $API_3 $FROZEN) +; ($REVISION) = '$Revision: 3.12.2.7.2.4 $' =~ m/Revision:\s*(\S+)/; $VERSION = '3.95'; $NAME = 'CGISESSID';

I've checked the various docs/lists but can't find anything... I hope you have some suggestions for me.

Thanks...jon

Replies are listed 'Best First'.
Re: CGI::Session autoload failure
by antirice (Priest) on Jan 09, 2004 at 19:06 UTC

    I don't see it anywhere in the code that you've posted but somewhere you seem to call $Session->expired. It does not appears in CGI/Session.pm or CGI/Session/File.pm. You can try this quite simply with the following code:

    #!/usr/bin/perl -l use CGI::Session; use CGI; # you seem to use a CGI object for your id...don't know why $a = CGI::Session->new(undef,new CGI,{Directory=>'/tmp'}); sub test(&) { eval { $_[0]->() }; chomp $@; print ++$b,$",$@ ? "Died: $@":"Success"; } test { $a->expire }; # 1 Success test { $a->expires }; # 2 Success test { $a->expired }; # 3 Died test { $a->jesii }; # 4 Died __END__ 1 Success 2 Success 3 Died: Can't locate auto/CGI/Session/File/expired.al in @INC ... 4 Died: Can't locate auto/CGI/Session/File/jesii.al in @INC ...

    Just search your code for $Session->expired. I hope this helps.

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1

      Thanks... Yes, I had used the wrong method name.

      Regarding your question about using a CGI object in the call to CGI::Session->new, that's because this is part of a CGI::Application program that I'm writing, and I need that object for other purposes.

      ...jon
Re: CGI::Session autoload failure
by cees (Curate) on Jan 09, 2004 at 18:51 UTC

    It sounds like somewhere in your code you are calling the method 'expired' on a CGI::Session object. This is not a valid method call. The reason you are not getting a standard perl error message is because CGI::Session uses AutoLoader to load less frequently used functions. 'expire' and 'expires' are two valid methods that are autoloaded on demand, and hence you found the files expire.al and expires.al. See the perldocs for AutoLoader for more info on how it works.

    -Cees

      Boy... did I overanalyze that problem :)

      You're right -- I had used the wrong method. Thanks very much!