To make an e-commerce site accessible even to those who have blocked cookies from their browser, is there any alternative way when creating a classic shopping cart to store cart data elsewhere while user is shopping?
CodePudding user response:
On modern browsers, localstorage can be used. For details, please refer to: https://javascript.info/localstorage
CodePudding user response:
Modern browsers provide WebStorage API for store data locally on the client system with capacity at least 5MB, and data never transferred to the server unlike cookies.
WebStorage API provides two object for storing data on the client:
- window.localStorage - stores data with no expiration date
- window.sessionStorage - stores data for one session (data is lost when the browser tab is closed)
https://www.w3schools.com/html/html5_webstorage.asp
https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
Modern browsers also provide IndexedDB API to storage of significant amounts of structured data on client system. This API uses indexes to enable high-performance searches of this data. While Web Storage is useful for storing smaller amounts of data, it is less useful for storing larger amounts of structured data.
https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
WebStorage API store and retrieve data as synchronize which means make main threat of web page blocked until data stored or retrieved. But operations performed using IndexedDB are done asynchronously, so as not to block applications.