I've been running site using mod_perl and HTML::Mason for 3-4 years with few problems. I recently am being asked to move everything to a new box that has Apache2 running on it (with mp2). I was able to install and get everything running for a site with no sessions and everything seems to be working fine. For another site, I was using Apache::Cookie for session management. I tried using the same code as for with mp1 with just changing the parse call to fetch (see code below). The cookies aren't working. As far as I can tell, cookie->new() is failing in Apache/Session/Generate/MD5.pm in the validate() function. I guess my question is first of all, am I going about this the right way? (It's been a while since I set up the original mp1 cookies code). Are people using the new Apache::Cookie (libapreq2)? The documentation I've been able to find for it is pretty sparse so far. Can somebody point me to some source code or better documentation than what I have found so far?

Here are the versions of stuff I am using:
Apache: 2.0.49
mod_perl: 1.99_13
libapreq2: 2.02_02


The following is the code in the handler running under mp1:

   my $cookies = Apache::Cookie->new($r)->parse;

eval {
tie (%HTML::Mason::Commands::session, 'Apache::Session::MySQL',
( $cookies->{'AF_SID'} ? $cookies->{'AF_SID'}->value() : undef ),
{ Handle => $main::SDBH, LockHandle => $main::SDBH });
};


# If the session is invalid, create a new session.
if ( $@ ) {
if ( $@ =~ m#^Object does not exist in the data store# ) {
tie (%HTML::Mason::Commands::session, 'Apache::Session::MySQL',
undef, { Handle => $main::SDBH, LockHandle => $main::SDBH });
undef $cookies->{'AF_SID'};
}
}


   if ( !$cookies->{'AF_SID'} ) {
       my $cookie = Apache::Cookie->new($r,
           -name=>'AF_SID',
           -value=>$HTML::Mason::Commands::session{_session_id},
           -path => '/',
       );
       $r->err_header_out('Set-Cookie' => "$cookie");
       $cookie->bake();
 }


And here is what I am using for mp2:


my $cookies = Apache::Cookie->fetch($r);

eval {
tie (%HTML::Mason::Commands::session, 'Apache::Session::MySQL',
( $cookies->{'AF_SID'} ? $cookies->{'AF_SID'}->value() : undef ),
{ Handle => $main::SDBH, LockHandle => $main::SDBH });
};


# If the session is invalid, create a new session.
if ( $@ ) {
if ( $@ =~ m#^Object does not exist in the data store# ) {
tie (%HTML::Mason::Commands::session, 'Apache::Session::MySQL',
undef, { Handle => $main::SDBH, LockHandle => $main::SDBH });
undef $cookies->{'AF_SID'};
}
}


   if ( !$cookies->{'AF_SID'} ) {
       my $cookie = Apache::Cookie->new($r,
           -name=>'AF_SID',
           -value=>$HTML::Mason::Commands::session{_session_id},
           -path => '/',
       );
       $rr->err_header_out('Set-Cookie' => "$cookie");
       $cookie->bake();
 }



--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Reply via email to