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

I downloaded the session module from cpan, unzipped it and placed it under my /site/lib/cgi directory (Yes I'm running windows). Then using the turtorial I wrote the following script, to see what I got.
use CGI::Session; $session = new CGI::Session(undef, $cgi, {Directory=>"/tmp"}); $sid=$session->id(); print "$sid \n";
What I got were these errors:
"mode" is not defined in %Fcntl::EXPORT_TAGS at C:\Products\Perl\lib/F +cntl.pm line 0 Can't call method "id" on an undefined value at C:\DOCUME~1\DWILSON\LO +CALS~1\Temp\dirD1.tmp\Untitled line 4.
Oh wise monks please show me the error of my ways (other than running windows)

Replies are listed 'Best First'.
Re: CGI::Session newbee
by dragonchild (Archbishop) on Apr 01, 2005 at 20:53 UTC
    First, you should check the return value of CGI::Session->new. That's kinda important.

    The second is your call should look something like:

    use CGI; use CGI::Session; use File::Spec; my $cgi = CGI->new; my $session = CGI::Session->new( undef, $cgi, { Directory => File::Spe +c->tmpdir } ) or die "Cannot create \$session!\n";
    /tmp isn't portable. :-)
Re: CGI::Session newbee
by ww (Archbishop) on Apr 01, 2005 at 21:33 UTC
    For what it's worth, you don't say what perl you're using, but if it's ActiveState, suggest you use ppm when feasible, as modules at AS are compiled for 'doze, which can, sometimes, save you agita.

    For example,

    C:\>ppm s CGI::Session
    produces
    1. CGI-Session [3.95] Persistent session in CGI applications 2. CGI-Session-Auth [0.23] Authenticated sessions for CGI scr +ipts 3. CGI-Session-BitBucket [1.0] a module that loses your session da +ta 4. CGI-Session-ExpireSessions [1.04] Delete expired CGI::Session db-ba +sed
    list trunacted...
    and welcome to the Monestary