I have a form which I would like to store the values of in a cookie so the user doesn't have to re-enter the form every visit. (The form is a few selects to filter search results.)
I would like for the cookie serialization to easily be readable from javascript (obviously to set the form onLoad), but I'd also like to be able to read the cookie easily from PHP (so that I can use the form data to filter search results).
How would I go about serializing a form with selects that have multiple="multiple" set into a cookie and have it be easily readable in javascript and PHP?
Please don't preach about validation, I'm doing that correctly on the server side.
If there's a smarter solution to my problem please let me know.
BTW: I'm using CodeIgniter on the server and Prototype/Scriptaculous javascript libraries.
Solution: Used Prototype's Object.toJSON(
Form.serialize(form, true))
for javascript, and used PHP's json_decode(string, bool)
to get an associative array in PHP from the JSON.