Pure Javascript - store object in cookie

前端 未结 4 964
无人及你
无人及你 2020-11-28 05:45

No jQuery.

I want to store an object or array in a cookie.

The object should be usable after page refresh.

How do I do that with pure JavaScript? I

4条回答
  •  -上瘾入骨i
    2020-11-28 05:58

    Use either object's own .toString() method if it gives meaningful serialization or JSON.stringify(). Do note, however, that cookies are usually limited in length and won't be able to hold big amounts of data.

提交回复
热议问题