CodeIgniter Forums
How To Encode/Decode Encrypted Cookies - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How To Encode/Decode Encrypted Cookies (/showthread.php?tid=36076)



How To Encode/Decode Encrypted Cookies - El Forum - 11-20-2010

[eluser]Christophe28[/eluser]
Hi,

Because of a bug in Flash I have to manually send the value of an encrypted cookie as a post parameter when uploading a file.

The value of the cookie looks a bit like:
Code:
ZXNddf2DN4V8i4Ei/wc9qpADEG1yB1A3BjiW9s/xBlF9+8x7D6+MFAc5yF%2
FWAgw2/ER4klwIPd5ZkBsTzbm+dBDdgRwqb3Hysr3lxNk2o8GG1c4TgLgP1Ci3Ns7Vs6fP
/LGOMC3hfUZOJmA5YcK9pYx1Xb2dGJgVta.......

But when it is send to the server as a post parameter the symbols like % are all taken out.

Is there a way to encode this cookie in JavaScript, send it to the server and decode it at the server?

Thanks for your help!

Christophe


How To Encode/Decode Encrypted Cookies - El Forum - 11-20-2010

[eluser]Twisted1919[/eluser]
I use base64_encode() and base64_decode() to avoid the problem you describe .


How To Encode/Decode Encrypted Cookies - El Forum - 11-20-2010

[eluser]Christophe28[/eluser]
Hi,

It works! :-) Thanks!

I'm just wondering one thing ...

To make the code in the application organized, I want to paste encode/decode functions in a separate encoding.js file. But when I call an encoding function from the sitewide.js file, it says it is not defined ...?

Why can't I call functions from another JS file?

Christophe