To store data in the a browser like chrome, there are plenty of options. These are the inbuild ones:

  • Cookies
  • Local storage
  • Session storage
  • IndexedDB
  • Web Storage API
FeatureCookiesLocal StorageSession StorageIndexedDBWeb Storage API (Overall)
TypeKey-value storeKey-value storeKey-value storeObject store (structured)Combination of above
PersistenceSession or persistentPersistentSession onlyPersistentDepends on type
Storage LocationServer-side (sent with requests)Client-side (browser)Client-side (browser)Client-side (browser)Client-side (browser)
Data CapacityUp to 4KB per cookieUp to 5-10MB (varies)Up to 5-10MB (varies)Up to 250MB (varies)Up to 5-10MB (varies)
Data TypeStrings onlyStrings onlyStrings onlyObjects and stringsStrings and potentially objects
APIDocument.cookielocalStoragesessionStorageIndexedDB APILocalStorage and SessionStorage APIs
Data Sharing with ServerYes, sent with requestsNoNoNoNo (indirectly through app logic)
SecurityMore vulnerable (exposed in requests)More secure (not sent to server)More secure (not sent to server)More secure (not sent to server)More secure (not sent to server)
Use CasesSession management, user preferences (limited data)User preferences, app state, large amounts of data (complex objects)Temporary data specific to a sessionLarge datasets, complex data structuresProvides access to LocalStorage and SessionStorage