What is the storage difference between session, cookies and localstorage? [duplicate]

2

Where is the storage location for each of them? the local storage I heard that it is html5 and is better than session and cookie , what is the difference between them?

    
asked by anonymous 29.09.2018 / 20:09

1 answer

2

Yes. Local storage and Session Storage are two methods that are part of the HTML5 DOM upgrade. We call these Web Storage methods. Local storage and session storage as all elements of the DOM can be handled with Javascript and / or Json. To be very objective I will explain this way:

Local Storage: With it you can privately store data in the browser. The data will be persisted until the user forces the method to destroy the object. Usage examples:

  • Forms where you want to store the data until the user completes the fill and submits. This prevents that in case of a power outage or an accidental closing of the browser the user has to type everything again.

In the case of session storage, the goal is the same. the only difference is that the data will be stored differently for each tab of the browser and if in case the user close the tab the data of that tab will be deleted automatically. Usage examples:

  • Shopping sites for tickets, either by bus or air ticket.

Cookies: These are files that serve the same purposes of storing user data for use in the application / site. The difference is that cookies are stored on the client computer and have inferior performance compared to web storage. Example usage:

  • Storing searches, storing pages accessed, etc.

Session: Protocol / method used to create the communication line in an authenticated way between your user and the program / application to be used. That is, in the session the data must be encrypted in the transmission. Example usage:

  • User login on facebook, in stackoverflow, authentication of users in corporate proxy, among others.

I hope I have helped. Big hug. \ o /

    
29.09.2018 / 21:06