Cookie help - using both cgi.pm and APR::Request::Cookie
am 28.05.2008 02:41:37 von Chris Faust
This is a multi-part message in MIME format.
------_=_NextPart_001_01C8C05B.9628D016
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Folks,
=20
I taking over some really old code and I'm in the process of converting =
it over to mp2. I want to be able to use APR::Request::Cookie to create =
the cookie for the new things I'm doing but I need to create it exactly =
like CGI.pm is currently doing so the old code will continue to work =
until I get everthing updated.
=20
I'm hoping someone knows both methods enough to tell me what I'm doing =
wrong.
=20
The CGI.pm cookie is being created like:
$query->cookie(-name=3D>'name',-value=3D>[val1,val2,val3,val 4,val5,val6,v=
al7],-expires=3D>'+5y',-domain=3D>www.domain.com,-path=3D>/) ;
=20
=20
I do my cookies like:
my $packed_cookie =3D APR::Request::Cookie->new($r->pool,
name =3D> 'name',
value =3D> $cookie_value, =20
path =3D> '/',
domain =3D> 'www.domain.com',
expires =3D> +5y,
); =20
$r->err_headers_out->add('Set-Cookie' =3D> $packed_cookie->as_string);
=20
For the value I made an array
@cookie_value =3D ('val1','val2','val3','val4','val5',val6','val7');
=20
In $packed_cookie I tried using @cookie_value directly, I tried it as an =
arrayref ($cookie_value), I tried it like [@cookie_value] etc and not =
matter what I do I can't get the old code to read it via
=20
my ($val1,$val2,$val3,$val4,$val5,$val6,$val7) =3D =
$query->cookie(-name=3D>'name');
=20
The cookie is getting set though, I can view it from within Mozilla. It =
just isn't being read by CGI.pm
=20
Does anyone know what I'm doing wrong?
=20
TIA!!
=20
=20
------_=_NextPart_001_01C8C05B.9628D016
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
=0A=
=0A=
=0A=
=0A=
Folks,
=0A=
=0A=
I taking over some really old code and =
I'm in the process of converting it over to mp2. I want to be able to =
use APR::Request::Cookie to create the cookie for the new things I'm =
doing but I need to create it exactly like CGI.pm is currently doing so =
the old code will continue to work until I get everthing =
updated.
=0A=
=0A=
I'm hoping someone knows both methods =
enough to tell me what I'm doing wrong.
=0A=
=0A=
The CGI.pm cookie is being created =
like:
=0A=
size=3D2>$query->cookie(-name=3D>'name',-value=3D>[val1,val2,val=
3,val4,val5,val6,val7],-expires=3D>'+5y',-domain=3D>www.domain.com,=
-path=3D>/);
=0A=
=0A=
=0A=
I do my cookies like:
=0A=
my $packed_cookie =3D =
APR::Request::Cookie->new($r->pool,
&nbs=
p; =
name =3D> =
'name',
&n=
bsp; value =3D> =
$cookie_value,  =
; =
&nb=
sp; path =3D> =
'/',
 =
; domain =3D> =
'www.domain.com',
&nbs=
p; expires =3D> =
+5y,
 =
; =
);
$r->err_headers_out->add('Set-C=
ookie' =3D> $packed_cookie->as_string);
=0A=
=0A=
For the value I made an =
array
=0A=
@cookie_value =3D =
('val1','val2','val3','val4','val5',val6','val7');
=0A=
=0A=
In $packed_cookie I tried using =
@cookie_value directly, I tried it as an arrayref ($cookie_value), =
I tried it like [@cookie_value] etc and not matter what I do I can't get =
the old code to read it via
=0A=
=0A=
my =
($val1,$val2,$val3,$val4,$val5,$val6,$val7) =3D =
$query->cookie(-name=3D>'name');
=0A=
=0A=
The cookie is getting set though, I can =
view it from within Mozilla. It just isn't being read by =
CGI.pm
=0A=
=0A=
Does anyone know what I'm doing =
wrong?
=0A=
=0A=
TIA!!
=0A=
=0A=
------_=_NextPart_001_01C8C05B.9628D016--
Re: Cookie help - using both cgi.pm and APR::Request::Cookie
am 28.05.2008 12:27:14 von aw
I don't guarantee that this is the real issue you're having, but be
careful of the following : either of the Apache2::Request::Cookie or
CGI::Cookie (don't remember which one) URL-encodes the cookie value by
default, and the other one does not. Maybe you're getting caught by that.
One of the modules above offers a "raw_cookie" method to get around
this, but again I don't remember which one.
cfaust-dougot wrote:
> Folks,
>
> I taking over some really old code and I'm in the process of converting it over to mp2. I want to be able to use APR::Request::Cookie to create the cookie for the new things I'm doing but I need to create it exactly like CGI.pm is currently doing so the old code will continue to work until I get everthing updated.
>
> I'm hoping someone knows both methods enough to tell me what I'm doing wrong.
>
> The CGI.pm cookie is being created like:
> $query->cookie(-name=>'name',-value=>[val1,val2,val3,val4,va l5,val6,val7],-expires=>'+5y',-domain=>www.domain.com,-path= >/);
>
>
> I do my cookies like:
> my $packed_cookie = APR::Request::Cookie->new($r->pool,
> name => 'name',
> value => $cookie_value,
> path => '/',
> domain => 'www.domain.com',
> expires => +5y,
> );
> $r->err_headers_out->add('Set-Cookie' => $packed_cookie->as_string);
>
> For the value I made an array
> @cookie_value = ('val1','val2','val3','val4','val5',val6','val7');
>
> In $packed_cookie I tried using @cookie_value directly, I tried it as an arrayref ($cookie_value), I tried it like [@cookie_value] etc and not matter what I do I can't get the old code to read it via
>
> my ($val1,$val2,$val3,$val4,$val5,$val6,$val7) = $query->cookie(-name=>'name');
>
> The cookie is getting set though, I can view it from within Mozilla. It just isn't being read by CGI.pm
>
> Does anyone know what I'm doing wrong?
>
> TIA!!
>
>
>
RE: Cookie help - using both cgi.pm and APR::Request::Cookie
am 28.05.2008 18:49:00 von Chris Faust
This is a multi-part message in MIME format.
------_=_NextPart_001_01C8C0E3.15F65E6B
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi Andre,
=20
That was is. Once I created the cookie value like
=20
my $cookie_value =3D qq|$val1&$val2&$val3.....|;=20
=20
It worked! Now I just got to update everything so I don't need to do =
that anymore :)
=20
Thanks!
-Chris
________________________________
From: Andr=E9 Warnier [mailto:aw@ice-sa.com]
Sent: Wed 5/28/2008 6:27 AM
To: cfaust-dougot
Cc: modperl@perl.apache.org
Subject: Re: Cookie help - using both cgi.pm and APR::Request::Cookie
I don't guarantee that this is the real issue you're having, but be
careful of the following : either of the Apache2::Request::Cookie or
CGI::Cookie (don't remember which one) URL-encodes the cookie value by
default, and the other one does not. Maybe you're getting caught by =
that.
One of the modules above offers a "raw_cookie" method to get around
this, but again I don't remember which one.
cfaust-dougot wrote:
> Folks,
>=20
> I taking over some really old code and I'm in the process of =
converting it over to mp2. I want to be able to use APR::Request::Cookie =
to create the cookie for the new things I'm doing but I need to create =
it exactly like CGI.pm is currently doing so the old code will continue =
to work until I get everthing updated.
>=20
> I'm hoping someone knows both methods enough to tell me what I'm doing =
wrong.
>=20
> The CGI.pm cookie is being created like:
> =
$query->cookie(-name=3D>'name',-value=3D>[val1,val2,val3,val 4,val5,val6,v=
al7],-expires=3D>'+5y',-domain=3D>www.domain.com,-path=3D>/) ;
>=20
>=20
> I do my cookies like:
> my $packed_cookie =3D APR::Request::Cookie->new($r->pool,
> name =3D> 'name',
> value =3D> $cookie_value, =20
> path =3D> '/',
> domain =3D> 'www.domain.com',
> expires =3D> +5y,
> ); =20
> $r->err_headers_out->add('Set-Cookie' =3D> =
$packed_cookie->as_string);
>=20
> For the value I made an array
> @cookie_value =3D ('val1','val2','val3','val4','val5',val6','val7');
>=20
> In $packed_cookie I tried using @cookie_value directly, I tried it as =
an arrayref ($cookie_value), I tried it like [@cookie_value] etc and not =
matter what I do I can't get the old code to read it via
>=20
> my ($val1,$val2,$val3,$val4,$val5,$val6,$val7) =3D =
$query->cookie(-name=3D>'name');
>=20
> The cookie is getting set though, I can view it from within Mozilla. =
It just isn't being read by CGI.pm
>=20
> Does anyone know what I'm doing wrong?
>=20
> TIA!!
>=20
>=20
>
------_=_NextPart_001_01C8C0E3.15F65E6B
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Re: Cookie help - using both cgi.pm and =
APR::Request::Cookie=0A=
=0A=
=0A=
=0A=
=0A=
Hi =
Andre,
=0A=
=0A=
That was is. Once I created =
the cookie value like
=0A=
=0A=
my $cookie_value =3D =
qq|$val1&$val2&$val3.....|;
=0A=
=0A=
It worked! Now I just got to =
update everything so I don't need to do that anymore :)
=0A=
=0A=
Thanks!
=0A=
-Chris
=0A=
=0A=
=0A=
From: Andr=E9 Warnier =
[mailto:aw@ice-sa.com]
Sent: Wed 5/28/2008 6:27 =
AM
To: cfaust-dougot
Cc: =
modperl@perl.apache.org
Subject: Re: Cookie help - using both =
cgi.pm and APR::Request::Cookie
=0A=
=0A=
I don't guarantee that this is the real issue you're =
having, but be
careful of the following : either of the =
Apache2::Request::Cookie or
CGI::Cookie (don't remember which one) =
URL-encodes the cookie value by
default, and the other one does =
not. Maybe you're getting caught by that.
One of the modules =
above offers a "raw_cookie" method to get around
this, but again I =
don't remember which one.
cfaust-dougot wrote:
> =
Folks,
>
> I taking over some really old code and I'm =
in the process of converting it over to mp2. I want to be able to use =
APR::Request::Cookie to create the cookie for the new things I'm doing =
but I need to create it exactly like CGI.pm is currently doing so the =
old code will continue to work until I get everthing =
updated.
>
> I'm hoping someone knows both methods =
enough to tell me what I'm doing wrong.
>
> The CGI.pm =
cookie is being created like:
> =
$query->cookie(-name=3D>'name',-value=3D>[val1,val2,val3,val4,va=
l5,val6,val7],-expires=3D>'+5y',-domain=3D>www.domain.com,-path=3D&=
gt;/);
>
>
> I do my cookies =
like:
> my $packed_cookie =3D =
APR::Request::Cookie->new($r->pool,
> =
name =
=3D> =
'name',
> &nbs=
p; value =3D> =
$cookie_value,  =
;
> &nbs=
p; path =3D> =
'/',
> &=
nbsp; domain =3D> =
'www.domain.com',
> =
expires =3D> =
+5y,
> &=
nbsp; );
> =
$r->err_headers_out->add('Set-Cookie' =3D> =
$packed_cookie->as_string);
>
> For the value I =
made an array
> @cookie_value =3D =
('val1','val2','val3','val4','val5',val6','val7');
>
> =
In $packed_cookie I tried using @cookie_value directly, I tried it as an =
arrayref ($cookie_value), I tried it like [@cookie_value] etc and not =
matter what I do I can't get the old code to read it =
via
>
> my ($val1,$val2,$val3,$val4,$val5,$val6,$val7) =
=3D $query->cookie(-name=3D>'name');
>
> The =
cookie is getting set though, I can view it from within Mozilla. It just =
isn't being read by CGI.pm
>
> Does anyone know what =
I'm doing wrong?
>
> =
TIA!!
>
>
>
ML>
------_=_NextPart_001_01C8C0E3.15F65E6B--