Finally I come with a working solution.
sub getCookie {
my ( $r ) = @_;
# check for both 'Cookie' and 'Set-Cookie' HTTP headers
return $r->headers_in->{'Cookie'} || $r->headers_in->{'Set-Cookie'};
}
Hope this help new comers like me.
Thanks again guys
Thanks Fred
Younes
yperl a écrit :
Your'e right Fred.
The cookie is correctly sent.
The problem is that Apache doesn't sent the correct cookie header.
He sent 'Set-Cookie' instead of 'Cookie' (like in your case).
Here is what I've got:
# lwp-request -USe http://coro/gdlweb/resolver
GET http://coro/gdlweb/resolver
User-Agent: lwp-request/2.07
GET http://coro/gdlweb/resolver --> 200 OK
Connection: close
Date: Sat, 11 Mar 2006 10:00:02 GMT
Server: Apache/2.2.0 (Unix) GDLWeb-BnF/2.0 mod_ssl/2.2.0
OpenSSL/0.9.7i DAV/2 mod_perl/2.0.2 Perl/v5.8.8
Content-Length: 0
Content-Type: text/plain
Client-Date: Sat, 11 Mar 2006 10:00:02 GMT
Client-Peer: 192.168.1.3:80
Client-Response-Num: 1
Set-Cookie: ID=123456; path=/
X-Pad: avoid browser bug
Younes
Fred Moyer a écrit :
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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>
http://www.wiles.org
---------------------------------