I have it so that users can copy and paste objects from one page to another. I use cookies to hold the object data.
On very rare occasions the amount of data (when escaped) has exceeded the 4k limit.
There are two ways around this I can see.
- compress what goes into the cookie (in tests this will give me about 5 times the capacity)
- test the data and if it exceeds 4k, spread it across multiple cookies (building in some chaining mechanism so they can easily be reconstructed)
I think the first solution might just push the problem further under the carpet and will come back and bite me in months to come.
But is the second solution a good idea? Has anyone done it before or is there some other client side storage mechanism that would be better here?
NB: I have used sessvars.js elsewhere in the site and I have been looking at using jstorage
I’ve decided to go ahead and use jstorage as mentioned in the question. It’s a decent alternative to what I have and makes use of html 5 localstorage if the browser allows it.