|laziness, impatience, and hubris|
Compressing data structures for cookiesby gwg (Beadle)
|on May 08, 2007 at 21:49 UTC||Need Help??|
gwg has asked for the wisdom of the Perl Monks concerning the following question:
I would like to store some user settings in a cookie, and was wondering if anyone had any advice on methods for compressing and/or encoding the data, which would be in the form of a hash of arrays. Storing all possible settings using FreezeThaw to stringify the data gives a file of 402 bytes in size. The number and variety of compression and encoding modules is a bit overwhelming, so if anyone has any suggestions for a particularly suitable module, I would be most grateful!
Update / clarification:
I'm already using a local variant of CGI::Session to store data server-side. The problem is that there are two machines which run the program, and a user could be directed to either of the two (the sys admin says that each user is usually sent to the machine they were previously on, but it can't be guaranteed every time). The other thing is that the volume of users is such that it is not feasible to keep the session data for every person, and it would be better for users to be able to have their settings persist between sessions.
The data that I want to store isn't anything critical - there are five filters that users can set up for searching / viewing data, and it's these settings that I would like to put in the cookie. The cookie data would be compared against the list of valid parameters, so if users did have the inclination to tinker with the settings, the worst they could do would be to set the maximum possible filters, which you can do validly by setting those filters using the cgi.