Problems with CGI::Session in Perl

Problems with CGI::Session in Perl

am 08.08.2005 17:25:28 von David Staschover

Hi,

I'm trying to set up sessions in perl.

session1.cgi defines a new session and sets a cookie. In session2.cgi, the
correct session id is returned from the cookie, but when I initialize the
session, a new session is created.

The example is below. Any help would be appreciated!

Thanks,

- David

session1.cgi:
#!/usr/bin/perl
use CGI::Session;
use CGI;
$cgi = new CGI;
$session = new CGI::Session(undef,undef,{Dire­ctory=>'/tmp/sessions'});
$cookie = $cgi->cookie(CGISESSID => $session->id);
print $cgi->header( -cookie=>$cookie );
$sid=$session->id;
print "Session ID is $sid
";
print '';
exit;


session2.cgi
#!/usr/bin/perl
print "Content-type: text/html\n\n";
use CGI::Session;
use CGI;
$cgi = new CGI;
$sid=$cgi->cookie("CGISESSID")­;
$session = new CGI::Session(undef,$sid,{Direc­tory=>'/tmp/sessions'});
print "Original Session ID is $sid
";
$sid = $session->id();
print "New Session ID $sid
";
exit;

Re: Problems with CGI::Session in Perl

am 09.08.2005 02:15:24 von xhoster

"David Staschover" wrote:
> Hi,
>
> I'm trying to set up sessions in perl.
>
> session1.cgi defines a new session and sets a cookie. In session2.cgi,
> the correct session id is returned from the cookie, but when I initialize
> the session, a new session is created.

Is anything actually getting created in /tmp/sessions/?

If not, check permissions. CGI::Sessions seems to return successfully
even when it should not.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB