javascript - How to get the remaining capacity of browser cookies and solve the problem of insufficient capacity?
欧阳克
欧阳克 2017-06-12 09:30:41
0
4
892

We know that the size of the cookie that the browser itself can store is limited. If the maximum capacity is exceeded, cookies cannot be set anymore. How to ensure that the remaining capacity is sufficient during development? Assuming that a user visits a website and fills up its cookie, does it mean that subsequent websites visited cannot set cookies normally?

欧阳克
欧阳克

温故而知新,可以为师矣。 博客:www.ouyangke.com

reply all(4)
迷茫

The length of the string is document.cookie.length, and then the byte conversion is done

迷茫

Use localstorage instead of cookies

仅有的幸福

The capacity of cookie is 4K.
You can use localstorage instead of cookies.
The corresponding one is sessionstorage.

習慣沉默

The cookie is only 4k. If you want to save it, it is recommended to use localstorage. In addition, if you want to simulate the cookie time clearing, you can simply use the cookie to save a time to judge the storage time of localstorage, and it will be cleared at that time

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template