|
Posted by Jon Slaughter on 05/18/07 13:47
"Toby A Inkster" <usenet200703@tobyinkster.co.uk> wrote in message
news:8220i4-8oj.ln1@ophelia.g5n.co.uk...
> Jon Slaughter wrote:
>
>> What I'm essentially doing is encrypting the name/data then encoding it
>> using base64 but base64 uses the special characters +, /, and =. They
>> seem
>> to be causing problems with the cook being written or read. I have
>> mapped
>> the ='s into _ and can map the + into - because I think those work for
>> cookies but I am not sure... and then I have the issue with the /. (which
>> I'm thinking of using _ for it too but have to handle the case where it
>> occurs at the end of the string to be encoded(Which will cause it to be
>> confused with the padding).
>
> Have you thought instead of using:
>
> $encoded = urlencode(base64_encode($data));
>
> This should create a string consisting of only alphanumeric data and '%'.
>
> To go back the other way:
>
> $data = base64_decode(urldecode($encoded));
>
I thought about it... but I didn't know if it would work. probably should
have tried it...
in any case, doesn't setcookie do that anyways? or does it just encode it
and not decode it? just kinda getting tired of trying everything as its not
easy to debug the cookies since I cannot set a cookie in the zend debugger
for some reason.
it does seem to be working now though when I have converted /, =, and + into
#, - and _..
I assume that urlencode is idempotent? else it won't work if I use
setrawcookie and it is not url decoding
Once I finish the code completely I'll go back and look at all this mess and
see what I can do to improve it.
Thanks,
Jon
[Back to original message]
|