On Jun 6, 2006, at 4:48 PM, Matthew wrote:

It could be that I just don't understand completely the nature of mod_perl, but here goes.

in a nutshell mod_perl lets you do at least these three things:
        compile cgi scripts into apache at runtime
create mod_perl handlers that replace cgi scripts and do things on urls. fun.
        let you script/interface with the apache server lifecycle

Reason I'm confused is because there exists CGI::Cookie for handling cookies in MP2, but there's also the libapreq library "for MP2". It seems to me that the apreq lib is more "MP2 Native" than CGI would be. Am I wrong? Are they equally 'native' ?
libapreq is more for interfacing with apache get/post data,
the perl glue is native to either mp1 or mp2, but there is a c api for both

With that in mind, I'm looking for some module, that I'm sure exists, that can manage sessions. I found Apache::Session but I couldn't tell if it was MP2 native. Is there something else I should be using for sessions that is 'better' with MP2?

i like apache session.  it works great under mp2

this is all cut from a custom session wrapper i have for handling sessions/cookies

checking for a cookie
        my      $sessionID;
        eval
        {
my $cookiejar = Apache2::Cookie::Jar->new( $self-> {'ApacheRequest'} );
                my      @names          = $cookiejar->cookies();
if ( $cookiejar->cookies( $self->{'CookieDefaults'}{'names'} {'Session'} ) )
                {
                        my      %c_cookies = Apache2::Cookie->fetch( 
$self->{'ApacheRequest'} );
my $c_value = $c_cookies{ $self->{'CookieDefaults'}{'names'} {'Session'} }->value;
                        $sessionID = $self->__session__validate( $c_value );
                }
        };
        if ( $@ )
        {
                print STDERR "\nERROR - can not parse cookie";
        }
        return $sessionID;


setting a cookie
                my      $cookie = Apache2::Cookie->new       
                (
                        $self->{'ApacheRequestRec'},
                        -name           => $name   ,
                        -value          => $value  ,
                        -expires        => $expiry ,
                        -secure         => $secure ,
                );
                        $cookie->path( $self->{'CookieDefaults'}{'path'} );
                        $cookie->domain( $domain );
                print STDERR "\n Baking cookie - $domain ";
$self->{'ApacheRequestRec'}->err_headers_out->add('Set-Cookie' => $cookie);

Reply via email to