Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Cookies Becoming Obsolete? Cookies vs. Browser Data Stores

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

like image 405
mattkgross Avatar asked Dec 31 '14 08:12

mattkgross


1 Answers

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

like image 52
T.J. Crowder Avatar answered Oct 18 '22 18:10

T.J. Crowder