Cookie help - using both cgi.pm and APR::Request::Cookie
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,val5,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 [EMAIL PROTECTED] 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
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,val5,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 [EMAIL PROTECTED] 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
Hi Andre, That was is. Once I created the cookie value like my $cookie_value = qq|$val1&$val2&$val3.|; It worked! Now I just got to update everything so I don't need to do that anymore :) Thanks! -Chris From: André Warnier [mailto:[EMAIL PROTECTED] 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, > > 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,val5,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 [EMAIL PROTECTED] 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!! > > >