Simple Guidance For You In Web Storage & Cookie

Introduction

WEB STORAGE is a data structure that allows clients to store web data. A pattern for storing data as key/value pairs and retrieving data based on a key. Internally, persistent storage (Local Storage) and temporary storage (Session Storage) are separated, so that developer can use them selectively according to data persistence.

Web storage is similar to cookies in the web environment, however, there is a big difference between them.

User-Interface
Browser-Engine
UI-Backend
Rendering-Engine
Web-Storage
Network
Javascript-Transpiler

Web Storage

  • Key/Value pairs structure
  • Web Storage stores information of clients
  • Web storage stores information only in local
  • Web Storage provides development convenience by storing structured objects and strings (However, need to check the browser compatibility)

    Pros

    • Not to store data unnecessarily on the server.
    • Large Capacity (about 5MB, up to browser)
    • No expiration date

    Cons

    • Impossible to use for the browser not to support HTML5

    Local Storage :

    • Local storage permanently stores the information of clients (e.g auto-login)
    • Stored data can be stored permanently unless deleted it on purpose
    • Local Storage is created separately for each domain.
      Can store and search through the Local Storage of Windows global objects
    • Local Storage persists data even when the browser is closed
    • Local Storage shares data globally as long as the domain is the same

    Session Storage :

    • The session store deletes information of the client when the session ends (when browser is closed)
    • Session Storage has restrictions on data persistence and access scope
    • Session Storage data is also deleted when the browser is closed
    • Data is only available within the current browser context
    • Session Storage cannot share data with other browsers and other tabs, even if the domain is the same


Cookie

  • Cookies store information in local and server

    Pros

    • Browser compatibility

    Cons

    • Included in every HTTP request, burdening the server by API calls
    • Small Capacity (about 4KB), The maximum number of cookies per site is 20
    • No encode process -> Risk of user privacy
    • Have an expiration date