Discussion Locked

what is the difference between cookies and local storage?

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
what is the difference between cookies and local storage?

10 replies

by kees_b

Cookies are just small text files. In local storage you can store much more.

by old molases

Cookies

Has different expiration dates (both the server or client can set up expiration date)
The Client can't access the Cookies if the HttpOnly flag is true
Has SSL Support
Data are transferred on each HTTP request
4kb limit

Local Storage

Has no expiration date
Client only
Has no SSL support
Data are not transferred on each HTTP request
5 mb limit (check with the browser)

by jhonalbert

local Storage is an implementation of the Storage Interface. It stores data with no expiration date, and gets cleared only through JavaScript, or clearing the Browser Cache / Locally Stored Data.

Cookies are primarily for reading server-side, local storage can only be read by the client-side

by wisekaren123

1.Storage size, the official statement of local storage is 5M, but the storage size of cookies is smaller and related to the browser itself (about 4000 bytes)
2.The content stored by the cookie will remain in the header of the HTTP request and will be sent to the browser with each request; however, the local storage will only remain on the client side, and the browser request process will not be sent to the server side

by thomasmills472 edited

The Local Storage is designed for storage that spans multiple windows and lasts beyond the current session.
Cookies do not handle this case well because they are transmitted with every request.

by jakeclarke1985 edited

Cookies are smaller and send server information back with every HTTP request, while LocalStorage is larger and can hold information on the client-side.

by jackaverysento

Cookies and local storage serve different purposes. Cookies are mainly for reading server-side, whereas local storage can only be read by the client-side . Apart from saving data, a big technical difference is the size of data you can store, and as I mentioned earlier localStorage gives you more to work with.

This discussion is closed to new replies.