I need to save a form state (values for input elements).

But the form is not a standard html form so the browser would not save the form state.

I need to store the form state as cookie I cannot save anything on server side.

But the size of the cookie will be around 10 KB. How to do this? Anyone have a idea?

有帮助吗?

解决方案

Split the 10KB of data into multiple cookies (i.e. cookies with different names in the same domain) when saving and combine those cookie values when retrieving.

If I recall correctly, the standard size of a cookie in most modern browsers is ~4096 bytes (sometimes including the name, sometimes not) so bear this in mind when creating the cookies.

Also bear in mind that the data in the cookies could be tampered with so exercise due diligence when working with such data.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top