Are there any drawbacks to using localStorage instead of Cookies?

前端 未结 4 1397
花落未央
花落未央 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 19:54

    One point to add, unlike cookie normally shared cross protocol, the storages stick to same-origin policy. As a consequence sites share the same domain but hosted on different protocol do not share the stored data.

    Say if your website need to work across http and https. For example, when user clicked the "purchase link" they will land on https secured checkout, then the checkout won't be able to retrieve the data previously stored on http site, even when they share the same domain.

提交回复
热议问题