Thursday, May 17, 2012

the way the cookie crumbles

Today as a quick tool to help with some QA I made cookiemonster, a simple tool to go through all the cookies associated with the request and print out the cookie content.

Clearly not rocket surgery, but useful today! If you view the source of that file, you can see a little bit of odd JSON parse and stringify. We sometimes stuff JSON structures as cookies (a cheap and cheerful technique but you need to be aware that those cookies then get sent with every request for all non-CDN'd content - so don't overdo it!) and it's nice to use stringify's ability to format the content-- but a barse JSON parse and stringify would thrown exceptions for non-JSON'd data, so I catch that case and just treat it as a plain string.

No comments:

Post a Comment