While working at a local web project I came across a point
where I thought session handling could come in handy and
so I installed Apache::Session. I set up some cookie routines
and then went testing the whole thing. The first request
to my script correctly noticed that there is no session yet and
thus created the correct HTTP-Header. But the second request
didn't seem to finish. Looking at my process list I noticed that
a perl process was running and seemingly would not quit.
When I killed the process the output of the script was finally
send to the browser.
Eager to know what was going on I set up my Apache server and
Activestate's Komodo for remote debugging to see what was going on.
I noticed that the script was running fine through my code parts
but after the last line the DESTROY routine of Apache::Session::File
was called. I compiled the following list that shows the way the script
takes. The last line is a goto command that seemingly doesn't finish.
The list :
# line 38 Apache::Session::File
sub DESTROY {
...
$self->save; # leaves here to Apache::Session
...
}
# line 489 Apache::Session
sub save {
...
return unless (
$self->{status} & MODIFIED || #leaves here to line 313
...
# line 313 Apache::Session
sub MODIFIED () {2}; # off to line 497 (sub save)
# line 497 Apache::Session
sub save {
...
$self->acquire_write_lock; # up up and away to line 565
...
# line 565 Apache::Session
sub acquire_write_lock {
...
return if ($self->{lock} & WRITE_LOCK); # see you at line 539
...
# line 539 Apache::Session
sub WRITE_LOCK () {2}; # off to line 569 (sub acquire_write_lock)
# line 569 Apache::Session
sub acquire_write_lock {
...
$self->{lock_manager}->acquire_write_lock($self); # We are slow
+ly closing into
... # Apache::S
+ession::File::Lock
# line 51
# line 51 Apache::Session::File::Lock
sub acquire_write_lock {
...
flock($self->{fh}, LOCK_EX); # GOTO Fcntl line 203 (AUTOLOAD)
# line 203 Fcntl
sub AUTOLOAD {
...
goto &$AUTOLOAD; # That's all folks. This one won't work.
Am I doing something wrong? For reference
here is a modified version of my package that handles
the cookie stuff :
package Request;
use strict;
use base 'Exporter';
use vars qw(@EXPORT);
@EXPORT = qw (
handle_session
...
);
use Apache::Session::File;
use CGI;
sub handle_session
{
my $cgi = CGI -> new;
my %session;
my $session_cookie = $cgi -> cookie ('SID');
tie %session, 'Apache::Session::File', $session_cookie,
{
Directory => "../data/sessions",
LockDirectory => "../data/sessions"
};
unless ($session_cookie)
{
my $session_cookie = $cgi -> cookie (
-name =>'SID',
-value => $sessio
+n{_session_id}
);
print $cgi -> header (-cookie => $session_cookie);
print 'Mmmhh.. Cookie'; # debug purpose
}
else
{
print $cgi -> header;
print 'No cookie for you!'; #debug purpose
}
return \%session;
}
1;
I am using Apache 1.3.xx, ActiveState perl 631, Win32 and the
newest Apache::Session version (I think).
.pl files are handled by CGI at the moment but changing the
handling to PerlRun for example didn't help.
I am thankful for a helping hand.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.