trouble with CGI::Session

From: Rajesh (raj1_iit_at_yahoo.com)
Date: 05/07/04


Date: 7 May 2004 14:12:50 -0700

Hi,

I am using the CGI::Session module with ActivePerl in IIS server in
Windows 2000 environment.

I have 2 files to test. test.cgi and test2.cgi.

Test.cgi

##############################################

use CGI qw/:standard/;
use CGI::Session;
use Win32::ODBC;

my $cgi = new CGI;

## Creating a new session
my $session = CGI::Session->new(undef, undef,
{Directory=>"C:/WINNT/TEMP/"});

my $cookie;
$session->expire('+1h');

##Writing to the cookie
$cookie = $cgi->cookie(
                    -name=>"CGISESSID",
                    -value=>$session->id(),
                    -expires=>'+1h');
print $cgi->header( -cookie=>$cookie );
print start_html(-title=>'Main Page'));
$session->dump(File::Spec->tmpdir()."\\log1.txt");
print "<A HREF=\"test2.pl\">",$session->id(),"</A>";
print end_html;

The cookie is written , I verified it and the session file is also
created. Now I click to open the test2.pl page.

Test2.pl

#################################################################
use CGI qw/:standard/;
use CGI::Session;
use Win32::ODBC;

my $cgi = new CGI;
$sid = $cgi->cookie("CGISESSID");

$session = CGI::Session->new("driver:File" ,$sid ,
{Directory=>"C:/WINNT/TEMP" });

print header,
        start_html(-title=>'Main Page'));
print $sid," ", $session->id()," ",Directory=>File::Spec->tmpdir() ;
$session->dump(File::Spec->tmpdir()."\\log2.txt");
print end_html;

############################################################

The variable $sid takes the session id correctly from the cookie. I
verified that too. However, the module is creating a new session even
though $sid is not undef and the file for the session created earlier
exists.

Why is this happening?

To debug, I manually took the session id from the cookie and
substituted to create session.
That is, I replaced,
   $session = CGI::Session->new("driver:File" ,$sid
,Directory=>"C:/WINNT/TEMP" });
by,
 $session = CGI::Session->new("driver:File"
,"a9fb13d7b6af8b8b9954a69312780eb1", {Directory=>"C:/WINNT/TEMP" });

 in test2.pl and ran the perl script in command prompt (and not
through the server), using, perl test2.pl.

This time, it recognized the previous session and did not create a new
session file.

 So, I think the problem is somewhere in IIS configuration. Has
anybody experienced this problem before??

If so, please tell me what the problem is