Problem with CGI:Session

F

Francesco

Hi,

I'm in trouble with a CGI script : I use CGI:Session for the session
management, my problem is that sometimes the script lost the session ID
and so create a new session.
The problem occurs everytime I run the script from a computer behind a
proxy (the script is on a website) and occasionally when the pc is
connected directly to internet (or is inside the LAN of the webserver).

The script structure is quite simple, at top of the script I call
a sub for the session management, then I load a sub for the page
requested.
The first page contains the login form (an hidden field contains the
session ID), then I create a frameset with 3 frames.

I print in each frame the session ID and is (sometimes/everytime)
different.

I suppose that the problem is in the session management, this is my
routine :

sub session_manage {
#my $sid = $CGI::Q->param('CGISESSID') || $CGI::Q->url_param('CGISESSID')
|| undef;
my $sid = $CGI::Q->param('CGISESSID'); $session = new
CGI::Session("driver:File",$sid, {Directory=>'/tmp'});
$session->save_param( $CGI::Q);
$session->expire(600); # expire after 600 seconds $ParID =
"?CGISESSID=".$session->id;
}

Is there something wrong ?

Francesco
Freedev.it
 
J

James Willmore

On Sat, 08 Nov 2003 14:54:29 GMT
Francesco said:
I suppose that the problem is in the session management, this is my
routine :

sub session_manage {
#my $sid = $CGI::Q->param('CGISESSID') ||
$CGI::Q->url_param('CGISESSID')
|| undef;
my $sid = $CGI::Q->param('CGISESSID'); $session = new
CGI::Session("driver:File",$sid, {Directory=>'/tmp'});
$session->save_param( $CGI::Q);
$session->expire(600); # expire after 600 seconds $ParID =
"?CGISESSID=".$session->id;
}

Is there something wrong ?

This may be an odd question, but do you recycle the web server when
this happens? I ask because you're using the '/tmp' directory to
store the sessions. When I recycle my box (running SuSE Linux), I
have it set to clean the '/tmp' directory on a recycle. At work
(running RedHat Linux - notice a theme here :) ), I use an
application to clear the '/tmp' directory every 6 hours. I'm
wondering if this type of situation is happening there.

So, if this is the case, change where you store the sessions. This
may prevent the removal of session information when you don't want the
information removed. If possible, you could store the information in
a database (such as MySQL). The module in question has documentation
to walk you through this. That way, you're storing the important
session information in something that, hopfully, doesn't get cleared
out every so often.

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Stult's Report: Our problems are mostly behind us. What we have
to do now is fight the solutions.
 
F

Francesco

Il Sat, 08 Nov 2003 16:55:28 +0000, James Willmore ha scritto:

This may be an odd question, but do you recycle the web server when
this happens? I ask because you're using the '/tmp' directory to
store the sessions. When I recycle my box (running SuSE Linux), I
have it set to clean the '/tmp' directory on a recycle. At work
(running RedHat Linux - notice a theme here :) ), I use an
application to clear the '/tmp' directory every 6 hours. I'm
wondering if this type of situation is happening there.

The sript run on a test server, I clean the '/tmp' manually :)

I have more session file than I desire...

Francesco
Freedev.it
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top