You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Gokul P. Nair" <gp...@yahoo.com> on 2005/06/23 18:29:52 UTC
APR::* confusion in setting and retrieving cookies through libapreq2
Hello,
I'm trying two simple functions i.e. to set a cookie
and retrieve it. I'm using Apache2, mod_perl2 &
libapreq2-2.05 to do this.
I read in the libapreq2 mail archives that using
APR::* is recommended over the Apache2::Cookie modules
and that there was debate over dumping the Apache2::*
modules but were left behind only for backward
compatibilities. Please check this thread:
http://marc.theaimsgroup.com/?t=111695063000003&r=1&w=2
So after reading the above thread and this one:
http://marc.theaimsgroup.com/?t=111694486900009&r=1&w=2
i'm in total confusion as to which is the right way to
go about accomplishing 2 seemingly simple tasks of
setting and retrieving cookies. I've read the
documentation for APR::Request::Cookie and i'm unable
to figure out how to send the cookie after creating
one.
So, i've basically got this:
use APR::Request::Cookie;
my $cookie = APR::Request::Cookie->new($req,
name =>
"foo",
value =>
"bar",
domain =>
"whatever.com");
Now from here how do i bake the cookie or send it?
Also $req needs to be an object of type APR::Pool and
in the documentation for APR::Pool it is suggested
that it is good to use a request pool for these short
scoped requests. So would $req be created like this ?
$req = APR::Request::Apache2->handle($r)
It's quite obvious that i'm pretty confused at this
point with the new naming convention, so any help or
advice would be greatly appreciated.
Another question i have is this - I went through the
code for APR::Request::Cookie and I don't see method
definitions for most of the methods/subs listed in the
documentation, even in the base class i.e.
APR::Request. Are these methods implemented as
functions in C code that is then dynamically linked
and bootstrapped through the dynaLoader module?
Thanks,
Gokul P. Nair
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Re: APR::* confusion in setting and retrieving cookies through libapreq2
Posted by "Gokul P. Nair" <gp...@yahoo.com>.
Thanks for the response Malcom. This is what i have:
my $req = $r->pool();
my $cookie = APR::Request::Cookie->new
($req,
name => "test",
value => { product_id => $product_id,
qty => $qty },
path => '/',
domain => "192.168.1.155",
expires => '+1d'
);
$cookie->expires('+1d'); # i have this line just to
be double sure, still
no effect!
$r->headers_out->add('Set-Cookie'=>$cookie);
After this when i check the cookie set on my bowser
for this domain, the 'name' and 'expires' fields have
not been set! I'm clueless, is $r-headers_out ... the
right way of sending the cookie?
Thanks,
Gokul P. Nair
--- Malcolm J Harwood
<mj...@liminalflux.net> wrote:
> On Thursday 23 June 2005 12:29 pm, Gokul P. Nair
> wrote:
>
> > Also $req needs to be an object of type APR::Pool
> and
> > in the documentation for APR::Pool it is suggested
> > that it is good to use a request pool for these
> short
> > scoped requests. So would $req be created like
> this ?
> > $req = APR::Request::Apache2->handle($r)
>
> $r should already be your request object (an
> Apache2::RequestRec). In which
> case, to get a new pool, you just do: $r-pool->new
>
> > Another question i have is this - I went through
> the
> > code for APR::Request::Cookie and I don't see
> method
> > definitions for most of the methods/subs listed in
> the
> > documentation, even in the base class i.e.
> > APR::Request. Are these methods implemented as
> > functions in C code that is then dynamically
> linked
> > and bootstrapped through the dynaLoader module?
>
> Yes. The source will probably be in the .xs file for
> the appropriate module.
>
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com
Re: APR::* confusion in setting and retrieving cookies through libapreq2
Posted by Malcolm J Harwood <mj...@liminalflux.net>.
On Thursday 23 June 2005 12:29 pm, Gokul P. Nair wrote:
> Also $req needs to be an object of type APR::Pool and
> in the documentation for APR::Pool it is suggested
> that it is good to use a request pool for these short
> scoped requests. So would $req be created like this ?
> $req = APR::Request::Apache2->handle($r)
$r should already be your request object (an Apache2::RequestRec). In which
case, to get a new pool, you just do: $r-pool->new
> Another question i have is this - I went through the
> code for APR::Request::Cookie and I don't see method
> definitions for most of the methods/subs listed in the
> documentation, even in the base class i.e.
> APR::Request. Are these methods implemented as
> functions in C code that is then dynamically linked
> and bootstrapped through the dynaLoader module?
Yes. The source will probably be in the .xs file for the appropriate module.