Are there any drawbacks to using localStorage instead of Cookies?

前端 未结 4 1281
花落未央
花落未央 2020-12-23 19:30

On my previous websites, I used to use a cookie to display a pre-home page only on the first visit. That worked great (see for example here), but using cookies is not so tre

4条回答
  •  醉梦人生
    2020-12-23 20:06

    It doesn't look easy for the server to read the localStorage. That may come in handy though, knowing your data is all client-side, making it safe from sniffing.

    Cookies can't be written over, only added to and read:

    alert(document.cookie);
    document.cookie = "nope";
    alert(document.cookie);
    

提交回复
热议问题