最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Are Cookies Becoming Obsolete? Cookies vs. Browser Data Stores - Stack Overflow

programmeradmin0浏览0评论

I've been playing around with HTML5 and Javascript a lot lately and have been really impressed with the functionality of LocalStorage as well as SessionStorage. It got me to thinking - with the advent of these elements, is there really any discernible advantage to cookies anymore?

I am able to create both persistent as well as session dependent data (both lightweight as well as unhealthily robust objects) with these two data stores. What benefits, if any, do cookies provide over these? Is this the end of the road for our favorite web "treat"?

I've been playing around with HTML5 and Javascript a lot lately and have been really impressed with the functionality of LocalStorage as well as SessionStorage. It got me to thinking - with the advent of these elements, is there really any discernible advantage to cookies anymore?

I am able to create both persistent as well as session dependent data (both lightweight as well as unhealthily robust objects) with these two data stores. What benefits, if any, do cookies provide over these? Is this the end of the road for our favorite web "treat"?

Share Improve this question asked Dec 31, 2014 at 8:10 mattkgrossmattkgross 8012 gold badges13 silver badges25 bronze badges 1
  • 1 yes, overtime they will likely be unneeded with localStorage and other options that will e up. Cookies were made ~1994, 20 years is a good run in technology – abc123 Commented Dec 31, 2014 at 8:13
Add a ment  | 

1 Answer 1

Reset to default 9

...with the advent of these elements, is there really any discernible advantage to cookies anymore?

Yes: They get sent to the server with every request. That's what they were originally for, and that's their current purpose (well, and being a fallback for browsers that don't have web storage, but there are very few of those left). If you don't need the information sent to the server with every request (session identifiers, etc.), web storage or similar is your better choice.

Cookies were never a good choice for purely client-side data, because they add to the weight of requests and responses. They were just the only choice for a while. Now we have better client-side-only data storage choices, and we have cookies for the small set of use cases where you actually want information automatically sent to the server with every request.

发布评论

评论列表(0)

  1. 暂无评论