wertert has asked for the wisdom of the Perl Monks concerning the following question:
The basic script simply sets up a cookie and then simply increments a counter for the duration of the session.#!C:/perl/bin/perl -- use strict; use CGI qw/ :standard /; use CGI::Cookie; use CGI::Carp qw/ fatalsToBrowser /; use CGI::Session; my $q = new CGI; my $session = new CGI::Session("driver:File", $q->cookie('CGISESSID') || $q->param('CGISESSID') || und +ef, { Directory => 'C:/temp/test/area' } ) or die ($CGI::Session::errstr); my $session_id = $session->id(); print $session->header; print $q->start_html(-title=>"www\.test\.com");#, $q->Dump, $q->query_ +string; my $in=$session->param('loggedin'); print "in = ", ((defined $in) ? $in : "UNDEFINED"); my $count = $session->param("loggedin") || "1"; $session->param( "loggedin", ($count+1) ); print $q->end_html; sub not_called { my($count); print "hello - i am never called !"; #$count=$session->param( "loggedin"); <<<<< PROBLEM }
The line marked as '<<<<< PROBLEM' is giving me the problem. It's in a function which is never called. When the line is commented out the script works ok. When the line is uncommented I get a problem. The problem seems to be that CGI::session is no longer interested in saving anything to disk ( ie in the /temp/test/area area ). There is no session management occuring so session->id is different every time. Comment out the line and everything works well. I can't say how weird this is !!!! why a line which is never called could affect the program is beyond me.
Perl is v5.8.6 on windows. Web Server is Apache.
I'm really stuck here and this is the weirdest problem I've seen in all my days of using perl !
PS - just so we're clear the '<<<<< PROBLEM' label was added after the code was pasted to perlmonks. I am not trying to run the script with that in place ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: very strange problem with CGI::Session
by imp (Priest) on Aug 08, 2006 at 11:59 UTC | |
|
Re: very strange problem with CGI::Session
by dtr (Scribe) on Aug 08, 2006 at 10:00 UTC |