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

I've been playing around with HTML5 and Javascript a lot lately and have been really impressed wit

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745101472a4611299.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信