Is it possible to serialize a Javascript object variable and store it in cookies?

Is it possible to serialize a Javascript object variable and store it in cookies? Or is there another way to accomplish the same thing?

+5
source share
3 answers

If these objects are not sensitive (for example, you don’t care whether your users modify them), then serializing them into cookies will be fine if your objects are small enough not to cause problems.

If your cookies are sensitive (you must depend on them to the level of integrity) or you have large structures, why not consider storing these serialized objects in a permanent session that is stored on your server. You can then use cookies as a key or identifier to find out which session will be restored when your visitor returns. Thus, the size of your serialized objects and whether they can “fit” in the cookie no longer matters.

, , - , ( ), HTML5 . , cookie, . , , , , -. (. ) .

HTML5: http://blog.darkcrimson.com/2010/05/local-databases/

, !

+6

, , cookie. Base64.

?

+4

Yes, it is possible if the resulting row does not exceed the cookie size limit (4 KB)

+2
source

All Articles