I want to reduce the loading times on my websites by moving all cookies to local storage since they seem to have the same functionality List the pros and cons of using local storage for cookie functionality except for obvious compatibility issues?
Cookies and local storage serve different purposes Cookies are primarily for reading server-side , local storage can only be read by the client-side . Why does a client or a server need this data?
Local storage is not really useful if it's your server because you have to get it in the way of ajax or hidden fields or something This might be okay if the server only needs a small subset of the total data for each request
You'll want to leave your session cookie as a cookie either way though.
As per the technical difference, and also my understanding.
Apart from being an old way of saving data, Cookies give you a limit of 4096 bytes (4095, actually) — it's per cookie. Local Storage is as big as 5MB per domain — SO Question also mentions it.
localStorageis an implementation of the