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?
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