What is the main Difference between local storage vs cookies?
Can you explain with example:


About: Fullstack developer in ReactJs, Symfony4, NodeJs, Javascript, html5, css3, php and AWS.
What is the main Difference between local storage vs cookies?
Can you explain with example:

A cookie is basically just information (a string) in the HTTP header. It can therefore be modified on client and server side. 
The local/session storage is a key/value store in your browser and can therefore only be access on the client-side.

On a note, no one should be putting sensitive data in the Local Storage. This includes session IDs and JWTs. They are vulnerable if there is ANY possible XSS vulnerabilities, and while SQL Injection attacks today are mostly because of old tech, we are still finding XSS vulnerabilities.

I think this is true for every client side storage. It doesn't matter if it's stored in a cookie, indexdb or local storage. Tari is right. Never store sensitive data in such a storage.
Hope this helps
stackoverflow.com/questions/322066...