You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Philip M. Gollucci" <pg...@p6m7g8.com> on 2005/07/01 08:14:22 UTC

Re: Apache2::Cookie confusing path and domain

Gokul P. Nair wrote:
> --- "Philip M. Gollucci" <pg...@p6m7g8.com> wrote:
>>Crap I missed the missing name.
>>
>>Didn't try expires.  Its probably a bug.
>>
>>If you're interested in fixing it, you'll want to
>>look at
>>glue/perl/APR/Request/Cookie.xs
I found the problem but I'm not sure where to implement the solution in 
the apreq-code base yet.

Given this:

   my $cookie = APR::Request::Cookie->new($req, name => "foo", value => 
time(), path => '/cookie');

         print STDERR "$cookie\n";
         print STDERR Dumper $cookie;
         print STDERR "name: " . $cookie->name() . "\n";

Prints:
1120197880
$VAR1 = bless( do{\(my $o = 163598384)}, 'APR::Request::Cookie' );
name: foo


the first line should have been

foo=1120197880; path=/cookie;

the "as_string()" method being called by "" overloading is apparently 
not the same one as the Apache2::Cookie.  The APR::Request::Cookie only 
returns the value not the full stringification.




-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Developer / Liquidity Services, Inc.
	http://www.liquidityservicesinc.com

Re: Apache2::Cookie confusing path and domain

Posted by "Gokul P. Nair" <gp...@yahoo.com>.
> $r->err_headers_out->add('Set-Cookie' =>
> sprintf("%s", 
> $cookie->as_string));

or the code below would suffice too.

$r->headers_out->add('Set-Cookie'=>$cookie->as_string);

Gokul P. Nair

--- "Philip M. Gollucci" <pg...@p6m7g8.com> wrote:

> Gokul P. Nair wrote:
> 
> >also 
> >printf "Set-Cookie: %s\n", $cookie->as_string;
> >
> >displays the right values i.e. in my case
> >
> >Set-Cookie: foo=bar; path=/; expires=Sat,
> 02-Jul-2005
> >14:34:42 GMT
> >  
> >
> I agree.
> 
> http://p6m7g8.net/cookie is update to the below:
> Seems to work for me.
> 
> sub handler () {
> 
>         my $r = shift;
>         my $req = $r->pool();
> 
>         my $cookie = APR::Request::Cookie->new($req,
> name => "foo", 
> value => time(), path => '/cookie');
> 
>         $r->err_headers_out->add('Set-Cookie' =>
> sprintf("%s", 
> $cookie->as_string));
> 
>         $r->print("Content-Type: text/plain\n\n");
>         $r->print("Testing....");
>         printf "Set-Cookie: %s\n",
> $cookie->as_string;
> 
>         return Apache2::Const::OK;
> }
> 
> 
> -- 
> END 
>
---------------------------------------------------------
>     What doesn't kill us can only make us stronger.
>                Nothing is impossible.
> 				
> Philip M. Gollucci (pgollucci@p6m7g8.com)
> 301.254.5198
> Consultant / http://p6m7g8.net/Resume/resume.shtml
> Senior Developer / Liquidity Services, Inc.
>      http://www.liquidityservicesinc.com
>         http://www.liquidation.com
>         http://www.uksurplus.com
>         http://www.govliquidation.com
>         http://www.gowholesale.com
> 
> 
> 



		
__________________________________ 
Discover Yahoo! 
Get on-the-go sports scores, stock quotes, news and more. Check it out! 
http://discover.yahoo.com/mobile.html

Re: Apache2::Cookie confusing path and domain

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Gokul P. Nair wrote:

>also 
>printf "Set-Cookie: %s\n", $cookie->as_string;
>
>displays the right values i.e. in my case
>
>Set-Cookie: foo=bar; path=/; expires=Sat, 02-Jul-2005
>14:34:42 GMT
>  
>
I agree.

http://p6m7g8.net/cookie is update to the below:
Seems to work for me.

sub handler () {

        my $r = shift;
        my $req = $r->pool();

        my $cookie = APR::Request::Cookie->new($req, name => "foo", 
value => time(), path => '/cookie');

        $r->err_headers_out->add('Set-Cookie' => sprintf("%s", 
$cookie->as_string));

        $r->print("Content-Type: text/plain\n\n");
        $r->print("Testing....");
        printf "Set-Cookie: %s\n", $cookie->as_string;

        return Apache2::Const::OK;
}


-- 
END 
---------------------------------------------------------
    What doesn't kill us can only make us stronger.
               Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Developer / Liquidity Services, Inc.
     http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com



Re: Apache2::Cookie confusing path and domain

Posted by "Gokul P. Nair" <gp...@yahoo.com>.
also 
printf "Set-Cookie: %s\n", $cookie->as_string;

displays the right values i.e. in my case

Set-Cookie: foo=bar; path=/; expires=Sat, 02-Jul-2005
14:34:42 GMT

Gokul P. Nair


--- "Philip M. Gollucci" <pg...@p6m7g8.com> wrote:

> Gokul P. Nair wrote:
> > --- "Philip M. Gollucci" <pg...@p6m7g8.com>
> wrote:
> >>Crap I missed the missing name.
> >>
> >>Didn't try expires.  Its probably a bug.
> >>
> >>If you're interested in fixing it, you'll want to
> >>look at
> >>glue/perl/APR/Request/Cookie.xs
> I found the problem but I'm not sure where to
> implement the solution in 
> the apreq-code base yet.
> 
> Given this:
> 
>    my $cookie = APR::Request::Cookie->new($req, name
> => "foo", value => 
> time(), path => '/cookie');
> 
>          print STDERR "$cookie\n";
>          print STDERR Dumper $cookie;
>          print STDERR "name: " . $cookie->name() .
> "\n";
> 
> Prints:
> 1120197880
> $VAR1 = bless( do{\(my $o = 163598384)},
> 'APR::Request::Cookie' );
> name: foo
> 
> 
> the first line should have been
> 
> foo=1120197880; path=/cookie;
> 
> the "as_string()" method being called by ""
> overloading is apparently 
> not the same one as the Apache2::Cookie.  The
> APR::Request::Cookie only 
> returns the value not the full stringification.
> 
> 
> 
> 
> -- 
> END
>
------------------------------------------------------------
>      What doesn't kill us can only make us stronger.
>                  Nothing is impossible.
> 				
> Philip M. Gollucci (pgollucci@p6m7g8.com)
> 301.254.5198
> Consultant / http://p6m7g8.net/Resume/resume.shtml
> Senior Developer / Liquidity Services, Inc.
> 	http://www.liquidityservicesinc.com
> 



		
____________________________________________________ 
Yahoo! Sports 
Rekindle the Rivalries. Sign up for Fantasy Football 
http://football.fantasysports.yahoo.com

Re: Apache2::Cookie confusing path and domain

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Gokul P. Nair wrote:

>>the "as_string()" method being called by ""
>>overloading is apparently 
>>not the same one as the Apache2::Cookie.  The
>>APR::Request::Cookie only 
>>returns the value not the full stringification.
>>    
>>
>
>Thats right, it says this in the documentation in
>CPAN: 
>"The double-quote interpolation operator maps to
>APR::Request::Cookie::value()"
>  
>
http://marc.theaimsgroup.com/?l=apreq-dev&w=2&r=1&s=as_string&q=b
You'll want to read these:

 18. 2005-04-22  Re: Apache::Cookies vs CGI::Cookies <http://marc.theaimsgroup.com/?l=apreq-dev&m=111420593713351&w=2>                   apreq-dev <http://marc.theaimsgroup.com/?l=apreq-dev&w=2> Joe Schaefer 
 19. 2005-04-22  Re: Apache::Cookies vs CGI::Cookies <http://marc.theaimsgroup.com/?l=apreq-dev&m=111420527425190&w=2>                   apreq-dev <http://marc.theaimsgroup.com/?l=apreq-dev&w=2> Bram 
 20. 2005-04-22  Re: Apache::Cookies vs CGI::Cookies <http://marc.theaimsgroup.com/?l=apreq-dev&m=111420250532704&w=2>                   apreq-dev <http://marc.theaimsgroup.com/?l=apreq-dev&w=2> Joe Schaefer 
 21. 2005-04-22  Re: Apache::Cookies vs CGI::Cookies <http://marc.theaimsgroup.com/?l=apreq-dev&m=111420153519727&w=2>                   apreq-dev <http://marc.theaimsgroup.com/?l=apreq-dev&w=2> Bram 
 22. 2005-04-22  Re: Apache::Cookies vs CGI::Cookies <http://marc.theaimsgroup.com/?l=apreq-dev&m=111419549824225&w=2>                   apreq-dev <http://marc.theaimsgroup.com/?l=apreq-dev&w=2> Joe Schaefer 
 23. 2005-04-22  Re: Apache::Cookies vs CGI::Cookies <http://marc.theaimsgroup.com/?l=apreq-dev&m=111413763310734&w=2>                   apreq-dev <http://marc.theaimsgroup.com/?l=apreq-dev&w=2> Joe Schaefer 
 24. 2005-04-20  Re: Apache::Cookies vs CGI::Cookies <http://marc.theaimsgroup.com/?l=apreq-dev&m=111405159230934&w=2>                   apreq-dev <http://marc.theaimsgroup.com/?l=apreq-dev&w=2> Bram 

I knew I remembered reading that once you said it.

-- 
END 
---------------------------------------------------------
    What doesn't kill us can only make us stronger.
               Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Developer / Liquidity Services, Inc.
     http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com



Re: Apache2::Cookie confusing path and domain

Posted by "Gokul P. Nair" <gp...@yahoo.com>.
> the "as_string()" method being called by ""
> overloading is apparently 
> not the same one as the Apache2::Cookie.  The
> APR::Request::Cookie only 
> returns the value not the full stringification.

Thats right, it says this in the documentation in
CPAN: 
"The double-quote interpolation operator maps to
APR::Request::Cookie::value()"

So its supposed to be returning just the value and not
the entire cookie string, but I'm not sure what this
would have to do with the "name" or "expires" tag not
being set under the cookie?

Thanks

Gokul P. Nair

--- "Philip M. Gollucci" <pg...@p6m7g8.com> wrote:

> Gokul P. Nair wrote:
> > --- "Philip M. Gollucci" <pg...@p6m7g8.com>
> wrote:
> >>Crap I missed the missing name.
> >>
> >>Didn't try expires.  Its probably a bug.
> >>
> >>If you're interested in fixing it, you'll want to
> >>look at
> >>glue/perl/APR/Request/Cookie.xs
> I found the problem but I'm not sure where to
> implement the solution in 
> the apreq-code base yet.
> 
> Given this:
> 
>    my $cookie = APR::Request::Cookie->new($req, name
> => "foo", value => 
> time(), path => '/cookie');
> 
>          print STDERR "$cookie\n";
>          print STDERR Dumper $cookie;
>          print STDERR "name: " . $cookie->name() .
> "\n";
> 
> Prints:
> 1120197880
> $VAR1 = bless( do{\(my $o = 163598384)},
> 'APR::Request::Cookie' );
> name: foo
> 
> 
> the first line should have been
> 
> foo=1120197880; path=/cookie;
> 
> the "as_string()" method being called by ""
> overloading is apparently 
> not the same one as the Apache2::Cookie.  The
> APR::Request::Cookie only 
> returns the value not the full stringification.
> 
> 
> 
> 
> -- 
> END
>
------------------------------------------------------------
>      What doesn't kill us can only make us stronger.
>                  Nothing is impossible.
> 				
> Philip M. Gollucci (pgollucci@p6m7g8.com)
> 301.254.5198
> Consultant / http://p6m7g8.net/Resume/resume.shtml
> Senior Developer / Liquidity Services, Inc.
> 	http://www.liquidityservicesinc.com
> 



		
__________________________________ 
Discover Yahoo! 
Use Yahoo! to plan a weekend, have fun online and more. Check it out! 
http://discover.yahoo.com/