You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by da...@apn.co.nz on 2004/10/22 05:29:37 UTC

Apache::Cookie seems to read different Cookie than CGI

Hi All

I have to read a domain cookie set by a ColdFusion Web Server on a 
different host. CF sets a cookie value like

user@domain.com|2004-10-22 16:16:41|70DC39BB99CB4CB826E3F30AA25D97FE

I can read this cookie with CGI.pm, and it seems to identical. When I try 
to get the same cookie value using Apache::Cookie, it gets returned as

user@domain.com|2004-10-22+16:16:41|70DC39BB99CB4CB826E3F30AA25D97FE

Note the '+' between the date and time. Unfortunately, this breaks 
everything, as I need the first two pipe delimited values to hash to the 
third value (using a key in addition to this). Does anyone know why this 
would happen, and if there is a workaround?

Regards

Dan

********************************************************************************
NOTICE
This email and any attachments are confidential. They may contain privileged 
information or copyright material. If you are not an intended recipient, you 
should not read, copy, use or disclose the contents without authorisation as 
we request you contact us as once by return email. Please then delete the 
email and any attachments from your system.  We do not accept liability in 
connection with computer viruses, data corruption, delay, interruption, 
unauthorised access or unauthorised amendment. Any views expressed in this 
email and any attachments do not necessarily reflect the views of the 
company.
********************************************************************************


Re: Apache::Cookie seems to read different Cookie than CGI

Posted by idstewart <id...@compuvative.com>.
dan.horne@apn.co.nz wrote:

>
> Hi All
>
> I have to read a domain cookie set by a ColdFusion Web Server on a 
> different host. CF sets a cookie value like
>
> user@domain.com|2004-10-22 16:16:41|70DC39BB99CB4CB826E3F30AA25D97FE
>
> I can read this cookie with CGI.pm, and it seems to identical. When I 
> try to get the same cookie value using Apache::Cookie, it gets 
> returned as
>
> user@domain.com|2004-10-22+16:16:41|70DC39BB99CB4CB826E3F30AA25D97FE
>
> Note the '+' between the date and time. Unfortunately, this breaks 
> everything, as I need the first two pipe delimited values to hash to 
> the third value (using a key in addition to this). Does anyone know 
> why this would happen, and if there is a workaround? 

If I were to hazard a guess, I would say that Apache::Cookie is URL 
encoding the cookie.  If you URL decode the value returned from 
Apache::Cookie, you should get the same value that is being reported by 
CGI.pm and Cold Fusion.

As a poor man's URL decode, you could try something like:

    $cookie =~ s/+/ /g;

This will replace the '+' with a space in the value returned by 
Apache::Cookie and leave the value returned by CGI.pm unaffected.


HTH.
Ian