You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by ben syverson <be...@elsif.org> on 2005/02/03 11:55:57 UTC
[mp2] Apache::Cookie only sets last cookie?
Hello,
I'm new to the list, although I've read so many of its messages I feel
like I subscribed weeks ago. :) I'm having some problems getting
libapreq2's Apache::Cookie to send out more than one cookie. The same
basic code worked fine in mp1, which makes me think I'm doing something
improperly. The code in question is contained within a subroutine in a
module that gets called from a registry script.
Here's the code:
$r = shift;
my $cookie = Apache::Cookie->new($r,
-name => 'id', -value => $id,
);
my $cookie2 = Apache::Cookie->new($r,
-name => 'chocolate_chip', -value => $chip,
);
$cookie->bake;
$cookie2->bake;
$r->content_type('text/html');
$r->print("just the chip comes through");
I'm using Apache 2.0.52, mod_perl-2.0.0-RC4, and libapreq2-2.04_03-dev.
Apache is configured down to only what is needed to run mod_perl and
libapreq2.
Should I cave and use CGI::Cookie to send these measly two cookies?
- ben
Re: [mp2] Apache::Cookie only sets last cookie?
Posted by ben syverson <be...@elsif.org>.
On Feb 3, 2005, at 2:25 PM, Joe Schaefer wrote:
> No that's not the problem. There's a bug in how 2.04 bakes
> cookies (it sets the table entry using apr_table_addn on a
> stack buffer instead of calling apr_table_add).
Blamo. That definitely explains it -- thanks!
>> It doesn't help that the libapreq2 test suite only
>> attempts to set one cookie. :)
>
> Yup. Patches are always welcome.
I'm interested in getting involved at that level soon, but for now I'm
just trying to stay afloat with my first big mod_perl project...
all the best,
- ben
Re: [mp2] Apache::Cookie only sets last cookie?
Posted by Joe Schaefer <jo...@sunstarsys.com>.
ben syverson <be...@elsif.org> writes:
> I haven't looked at the code, but I suspect that "bake" is
> accidentally doing the equivalent of $r->headers_out->set('Set-Cookie'
> => $cookie) rather than $r->headers_out->add('Set-Cookie' =>
> $cookie)...
No that's not the problem. There's a bug in how 2.04 bakes
cookies (it sets the table entry using apr_table_addn on a
stack buffer instead of calling apr_table_add). You should
be able to find a discussion of this isue somewhere in this
list's archives, as well as the patch which fixes it. Otherwise
I suggest you try using apreq's subversion trunk and see
if your problem goes away.
> It doesn't help that the libapreq2 test suite only
> attempts to set one cookie. :)
Yup. Patches are always welcome.
--
Joe Schaefer
Re: [mp2] Apache::Cookie only sets last cookie?
Posted by ben syverson <be...@elsif.org>.
On Feb 3, 2005, at 8:32 AM, Kurt Hansen wrote:
> Have you checked the expiration of your cookies?
Hi Kurt,
I cut out the expires, domain and path information to make a more
concise listing for email. The expires is set to '+12h,' and is set
fine for the last cookie out. I haven't looked at the code, but I
suspect that "bake" is accidentally doing the equivalent of
$r->headers_out->set('Set-Cookie' => $cookie) rather than
$r->headers_out->add('Set-Cookie' => $cookie)...
It doesn't help that the libapreq2 test suite only attempts to set one
cookie. :)
- ben
Re: [mp2] Apache::Cookie only sets last cookie?
Posted by Kurt Hansen <kh...@charityweb.net>.
ben syverson wrote:
> I'm new to the list, although I've read so many of its messages I feel
> like I subscribed weeks ago. :) I'm having some problems getting
> libapreq2's Apache::Cookie to send out more than one cookie. The same
> basic code worked fine in mp1, which makes me think I'm doing
> something improperly. The code in question is contained within a
> subroutine in a module that gets called from a registry script.
>
> Here's the code:
> $r = shift;
> my $cookie = Apache::Cookie->new($r,
> -name => 'id', -value => $id,
> );
> my $cookie2 = Apache::Cookie->new($r,
> -name => 'chocolate_chip', -value => $chip,
> );
> $cookie->bake;
> $cookie2->bake;
> $r->content_type('text/html');
> $r->print("just the chip comes through");
>
> I'm using Apache 2.0.52, mod_perl-2.0.0-RC4, and
> libapreq2-2.04_03-dev. Apache is configured down to only what is
> needed to run mod_perl and libapreq2.
>
> Should I cave and use CGI::Cookie to send these measly two cookies?
I'm using Apache 2.0.52, mp-1.99_17, and libapreq2-2.04_03.
Have you checked the expiration of your cookies? With libapreq2, not
specifying an expiration date has the expiration set to "now". With
libapreq1, not specifying an expiration date made it a session cookie.
So, with libapreq2-2.04_03, you need to specifically set the expires to
undef to make it a session cookie, e.g. "-expires=>undef".
Could that be your problem?
Take care,
Kurt