LetsSurf, >I've just finished writing a cookieJar plugin for jQuery, as I >couldn't find anything like it for jQuery. > >http://www.jdempster.com/category/code/jquery/cookiejar/ > >Thought I would post it here in the hope of some feedback. >Please let me know what you think. Is this a good approach to the >problem. If you found any problems or have any suggestions.
Looks interesting, but one suggestion I would make is to put a reminder prominently displayed on the page that reminds developers that: 1) Cookies are sent with each request header. 2) The total Cookie size per domain is generally 4K (which is per the spec http://www.ietf.org/rfc/rfc2109.txt.) This is not a per Cookie limit, but a total name-value pair. Here's what Microsoft says about IE: http://support.microsoft.com/kb/306070 "Each cookie begins with a name-value pair. This pair is followed by zero or by more attribute-value pairs that are separated by semicolons. For one domain name, each cookie is limited to 4,096 bytes. This total can exist as one name-value pair of 4 kilobytes (KB) or as up to 20 name-value pairs that total 4 KB. If the computer does not have sufficient space to store the cookie, the cookie is discarded. It is not truncated. Applications should use as few cookies as possible and as small a cookie as possible. Additionally, applications should be able to handle the loss of a cookie." I only point these out as important as it could be very tempting for a developer to want to stick a large JSON packet in a cookie, but they must know the repercussions of doing this. -Dan