Return-Path: Delivered-To: apmail-perl-modperl-archive@www.apache.org Received: (qmail 40629 invoked from network); 14 Mar 2006 20:56:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Mar 2006 20:56:10 -0000 Received: (qmail 52275 invoked by uid 500); 14 Mar 2006 20:56:05 -0000 Delivered-To: apmail-perl-modperl-archive@perl.apache.org Received: (qmail 51886 invoked by uid 500); 14 Mar 2006 20:56:03 -0000 Mailing-List: contact modperl-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list modperl@perl.apache.org Received: (qmail 51875 invoked by uid 99); 14 Mar 2006 20:56:03 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Mar 2006 12:56:03 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of yperl@club-internet.fr designates 194.158.104.39 as permitted sender) Received: from [194.158.104.39] (HELO relay-cm.club-internet.fr) (194.158.104.39) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Mar 2006 12:56:02 -0800 Received: from [192.168.1.3] (i01v-62-35-95-95.d4.club-internet.fr [62.35.95.95]) by relay-cm.club-internet.fr (Postfix) with ESMTP id B5AAD2560F; Tue, 14 Mar 2006 21:55:41 +0100 (CET) Message-ID: <44172EFC.1090506@club-internet.fr> Date: Tue, 14 Mar 2006 22:00:44 +0100 From: yperl User-Agent: Thunderbird 1.5 (X11/20051201) MIME-Version: 1.0 To: Geoffrey Young Cc: modperl@perl.apache.org Subject: Re: APR::* + PerlResponseHandler + Reading Cookie References: <44171C3E.2050109@modperlcookbook.org> <4417264A.8070404@club-internet.fr> <441728E0.1090202@modperlcookbook.org> In-Reply-To: <441728E0.1090202@modperlcookbook.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Reinveting the wheel its in my nature to understand things :-) Hope that all anwsers are in chapter 13 (good number). Thanks Geoffrey for all this explanations. cheers Younes Geoffrey Young a �crit : > in the future please keep responses on list :) > > yperl wrote: > >> Geoffrey Young a �crit : >> >> >>> I find myself wondering if you're trying to set the cookie in one >>> phase and >>> read it from the PerlResponseHandler _during the same request_? >>> >>> >> Yes. Is that usage not recommended? >> Nothing in the doc is against that. >> > > it wouldn't be in the docs - it's the nature of the HTTP protocol and how > cookies interact with it. > > >> I'm creating the cookie in a PerlAccessHandler and reading it from >> a PerlResponseHandler, in the same request. >> > > nope, can't do that :) > > it works like this... > > your access handler will set the Set-Cookie header, which goes to the > client. when you try to read the cookie in from your PerlResponseHandler > you aren't at the client yet, so there's no cookie to read back in yet - the > client has yet to receive your cookie :) > > on the _next_ request the client will sent the Cookie header with its > request and then you'll be able to glean it in your application. > > [lots of stuff snipped] > > >> GET http://coro/gdlweb/resolver >> User-Agent: lwp-request/2.07 >> >> GET >> http://coro/gdlweb/resolver?utilisateur=sara&motdepasse=sara&target=accueil >> --> 200 OK >> Connection: close >> Date: Tue, 14 Mar 2006 20:15:47 GMT >> Server: Apache/2.2.0 (Unix) GDLWeb-BnF/0.3 mod_ssl/2.2.0 OpenSSL/0.9.7i >> DAV/2 mod_apreq2-20051231/2.5.7 mod_perl/2.0.3-dev Perl/v5.8.8 >> Content-Length: 0 >> Content-Type: text/plain >> Client-Date: Tue, 14 Mar 2006 20:15:47 GMT >> Client-Peer: 192.168.1.3:80 >> Client-Response-Num: 1 >> Set-Cookie: foo=1142367347; path=/ >> > > yup, there it is. > > >> * Apache output: >> >> [Tue Mar 14 21:10:33 2006] [error] access to /gdlweb/resolver failed for >> 192.168.1.3, reason: >>> cookie: none >> >> [Tue Mar 14 21:10:33 2006] [error] access to /gdlweb/resolver failed for >> 192.168.1.3, reason: >>> JAR: $VAR1 = 'GET /gdlweb/resolver >> HTTP/1.1\nTE: deflate,gzip;q=0.3\nConnection: TE, close\nHost: >> coro\nUser-Agent: lwp-request/2.07\n\nHTTP/1.1 (null)\nSet-Cookie: >> foo=1142367347; path=/\n\n';\n >> >> >> >> We can easily see that the dumped object $r contains the cookie named >> "foo". >> > > no it doesn't. it has the Set-Cookie header it it, which is different from > the Cookie header the client will send you it has successfully registered a > cookie for your domain. > > but really, it sounds like you're trying to reinvent the wheel a bit - take > a look at Apache::AuthCookie on CPAN for cookie-based authentication. and > while you can find the nuances of cookies lots of places on the web, you > might find this a useful read as well, as there are lots of interesting > things you can do with cookies and authentication in general with mod_perl. > > http://www.modperlcookbook.org/chapters/ch13.pdf > > HTH > > --Geoff > >