perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Gormley <cl...@traveljury.com>
Subject Re: Apache2::Cookie/APR::Request::Cookie
Date Sat, 09 Dec 2006 13:53:29 GMT

>  
> The man page then says to use APR::Request::Cookie I should:
> my $jar = $r->jar;
> my $cookie = $jar->get("ISMH_SESSION_ID");

What is $r in this case? It should be an APR::Request::Apache2 or
(APR::Request::CGI I think) handle.

So, where $r is an Apache2::RequestRec object:

To set:
-------
        my $cookie = APR::Request::Cookie->new( 
            $r->pool,
            expires => '+7d',
            value => 'value',
            name  => 'name'
        ) or die;

        $r->err_headers_out->add( 'Set-Cookie', $cookie->as_string );
        
To read:
--------
        my $req = APR::Request::Apache2->handle( $r );
        my $jar = $req->jar;
        my %cookies;
        foreach my $key ( keys %$jar ) {
            $cookies{$key} = $jar->get($key);
        }


clint


Mime
View raw message