Difference between local storage vs cookies
Elango Sundar

Elango Sundar @10secondsofcode

About: Fullstack developer in ReactJs, Symfony4, NodeJs, Javascript, html5, css3, php and AWS.

Location:
India
Joined:
Oct 26, 2018

Difference between local storage vs cookies

Publish Date: Apr 11 '19
6 4

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

Comments 4 total

  • Klaus Herberth
    Klaus HerberthApr 11, 2019

    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.

    • Tari R. Alfaro
      Tari R. AlfaroApr 12, 2019

      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.

      • Klaus Herberth
        Klaus HerberthApr 14, 2019

        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.

Add comment