views:

151

answers:

2

I installed CGI::Session module on my host by creating the perl-modules directory in my cgi-bin and then extracting the module to that directory so I have:

D: cgi-bin/perl-modules/CGI/
F: cgi-bin/perl-modules/CGI/Session.pm
D: cgi-bin/perl-modules/CGI/Session/
F: cgi-bin/perl-modules/CGI/Session/File.pm
D: cgi-bin/perl-modules/CGI/Session/ID/
D: cgi-bin/perl-modules/CGI/Session/Searialize/

In a script I do (this is located in cgi-bin/test/):

     use lib '../perl-modules';
     use CGI::Session;
     $session = new CGI::Session (
                "driver:File", 
                undef,
                {Directory => '/tmp'}
            );

$session->param('_logged_in', 1);
$session->param('_remote_ua', $ENV{'HTTP_USER_AGENT'});
$session->expire('+2hr');

Everything works fine untill the call to expire. When I put the expire call inside an eval I get the following error:

Can't locate auto/CGI/Session/File/expire.al in @INC (@INC contains: ../perl-modules /usr/lib/perl5/5.8.7/i686-linux /usr/lib/perl5/5.8.7 /usr/lib/perl5/site_perl/5.8.7/i686-linux /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.7/i686-linux /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl .)

Any ideas?

+1  A: 

Latest CGI::Session distribution archive does not have CGI::Session::File - you must be using very old version. In new version, you need to write "driver:file" in new call (note case of 'f').

If you need that outdated version and can't install anything on hosting, install that version of CGI::Session locally, and copy "auto/CGI/Session/" directory from %Perl%/site/lib/ to hosting too. Another option is to do make without cpan shell and copy that dir from blib/arch.

Alexandr Ciornii
+1  A: 

I think your problem lies in relative pathing. It seems safe to assume that your script is being executed from Apache or another web server. In that case, ../perl-modules/ could be just about anywhere.

On my web server, the current working directory is /usr/local/apache22/, so ../perl-modules/ would resolve to /usr/local/apache22/../perl-modules, or /usr/local/perl-modules/. In order to overcome this, I'd suggest putting an absolute path in instead of a relative path. For example:

use lib '/home/user105033/perl-modules/';
Jack M.
Old CGI::Session uses Autoload, so this is not a problem with paths.
Alexandr Ciornii
Just thought it might have something to do with it, since there is an oddball `auto/` on the front of the error.
Jack M.