What’s the point in writing cookies if it’s hard to extract the values later. I prefer to write JSON into my cookies. This makes turning a cookie into a javascript object a very simple process. I use jquery and the cookie plugin.
var json=($.cookie('the_cookie'));
var obj = $.parseJSON(json);
Now your cookie has been converted into a javascript object and you’re ready to rock.
On the other side, if you want to create a json on the client and write it to a cookie you could use json2.js as well as cookie.js