perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Foo Ji-Haw <jhfoo...@extracktor.com>
Subject Re: Modperl2 + PerlAccessHandler + Sending Cookie
Date Mon, 13 Mar 2006 02:18:44 GMT
Wow, a little tangent to the topic here: I didn't know that you can do this
PerlResponseHandler Apache2::Const::OK
Is that 'legal'? It's interesting to know, but I wouldn't know of a 
practical use for this trick.

Another question: why do you use CGI::Cookie in place of Apache2::Cookie?

Last question: is it a best practice to do the user and access 
authentication check at the PerlAccessHandler level? I like the idea 
(obviously I've not been trying this way). A single authentication 
module that can be used across various PerlResponseHandler. Easy to 
maintain and propogate.

Fred Moyer wrote:
> yperl wrote:
>> unfortunately no. I've already tried this.
>
> Sometimes bad cookies leave no crumbs and are especially hard to track 
> down.  I'm guessing this has to do with the specifics of your cookie 
> values - can you show us the exact code you used to create it?
>
> I was able to successfully bake a cookie from a PerlAccessHandler with 
> the following code:
>
> package Cookie::Monster;
>
> use strict;
> use warnings;
>
> use Apache2::Const -compile => qw( OK );
> use CGI::Cookie;
>
> sub handler {
>     my $r = shift;
>     my $cookie = new CGI::Cookie( -name => 'ID', -value => 123456 );
>     $r->headers_out->add('Set-Cookie' => $cookie );
>     return Apache2::Const::OK;
> }
>
> 1;
>
> httpd.conf
>
> <Location /test>
>     SetHandler modperl
>     PerlAccessHandler Cookie::Monster
>     PerlResponseHandler Apache2::Const::OK
> </Location>
>
> Headers output:
>
> GET /test/ HTTP/1.1
> Host: localhost:7777
> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) 
> Gecko/20051201 Firefox/1.0.7
> Accept: 
> text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

>
> Accept-Language: en-us,en;q=0.5
> Accept-Encoding: gzip,deflate
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive: 300
> Connection: keep-alive
> Cookie: ID=123456
> Cache-Control: max-age=0
>
>>
>> Frank Wiles a écrit :
>>> On Sat, 11 Mar 2006 02:42:20 +0100
>>> yperl <yperl@club-internet.fr> wrote:
>>>
>>>  
>>>> I've tried everything I found (in mailing lists, suggestions, web doc)
>>>> to send cookie from a PerlAccessHandler, but without success.
>>>>
>>>> Before giving up, I would like to have an answer from the mod_perl2 
>>>> authors if it is possible.
>>>>
>>>> [snip]
>>>>
>>>>   if ( grantAccess() ) {
>>>>
>>>>       $r->headers_out->{'Set-Cookie'} = $cookie;
>>>>       return Apache2::Const::OK;
>>>>   }
>>>>     
>>>
>>>   Shouldn't that be:
>>>   $r->headers_out->add('Set-Cookie' => $cookie );
>>>  ---------------------------------
>>>    Frank Wiles <frank@wiles.org>
>>>    http://www.wiles.org
>>>  ---------------------------------
>>>
>>>   
>>
>


Mime
View raw message