You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Erik Arneson <ea...@musiciansfriend.com> on 2001/04/13 01:22:58 UTC

Apache::Cookie and encoding

Howdy folks,

I'd like to use Apache::Cookie, but I'm doing some tricky things with
cookie data, which requires that I do the encoding myself.  However,
every time I 'bake' a cookie object, it tries to encode stuff for me.  I
don't like this.

For example, if I've got cookie data that looks like 'foo%21', it
emerges from 'bake' looking like 'foo%2521'.  Is there any way to
prevent this behavior?

Thanks.

-- 
# Erik Arneson <ea...@musiciansfriend.com>   Web Engineer #
#  Mobile: 541.840.3100           GPG Key ID: 1024D/0A2C3C5E #
#  Office: 541.774.5391    <http://www.musiciansfriend.com/> #


RE: Apache::Cookie and encoding

Posted by Rob Bloodgood <ro...@empire2.com>.
> I'd like to use Apache::Cookie, but I'm doing some tricky things with
> cookie data, which requires that I do the encoding myself.  However,
> every time I 'bake' a cookie object, it tries to encode stuff for me.  I
> don't like this.
>
> For example, if I've got cookie data that looks like 'foo%21', it
> emerges from 'bake' looking like 'foo%2521'.  Is there any way to
> prevent this behavior?

First of all,
reading the cookie value in should reverse the weirdness (encoding)
that ->bake is doing.

Second of all,
if it's still a problem, you can either
A) design your cookie string to NOT use those characters (like, if % is a
separator, choose a : or something),
B) use Storable / MIME::Base64 / UUEncode ( which is as simple as pack('u',
$val) ! ) , or
C) encode it yourself.

Hope this helps!

L8r,
Rob