Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persistence lifetime

Tags:

indexeddb

I read few articles about IndexdDB, but couldn't find details about the lifetime of persisted data. I plan to use it for a session of data manipulation and upload once the user finishes. But what will happen if:

  • user close the browser tab
  • user closes the browser
  • user restarted the system

Also, I maintain user session through cookie based authentication. What will happen if the user logs off and log back in again? Is there a way to retrieve the data before the logoff?

Any documentation on handling this is appreciated. I skimmed through the spec, but it is not that good a read.

Thanks.

like image 551
bsr Avatar asked Apr 04 '13 16:04

bsr


People also ask

What is persistent cart?

What is a persistent cart? Persistent carts are a feature that preserves the items that a customer has placed in their shopping cart when they exit the site without purchasing, using a cookie that identifies the customer for future sessions, even on other devices.

How does the persistent shopping cart option work in Magento 2?

A persistent shopping cart in Magento is almost the same as a regular Magento shopping cart. However, the persistent cart can store products customers added to the cart for a period specified in the configuration, up to one year. The persistent cookie remains active even after the session cookies expire.


2 Answers

It's like localStorage, so it's cross-session, meaning restarting browser or system won't affect what is stored in it. However, user can clear it like clearing cookie. So it's just like persistent cookie, you don't trust it from the server-side, and you always need to check its integrity.

like image 172
Cat Chen Avatar answered Sep 21 '22 20:09

Cat Chen


Persistent Storage has been available in Chrome since v52 and Firefox since v55. Support in other browsers can't be relied on though. You must test if persistent storage is available and react accordingly.

if (navigator.storage && navigator.storage.persist) {   navigator.storage.persist().then(persistent => {     if (persistent) {       console.log("Storage will not be cleared except by explicit user action");     } else {       console.warn("Storage may be cleared by the UA under storage pressure.");     }   }); } 

Chrome requires permission to use this feature. It will automatically be granted when calling navigator.storage.persist() if any of the following are true:

  • The site is bookmarked (and the user has 5 or less bookmarks)
  • The site has high site engagement
  • The site has been added to home screen on mobile device
  • The site has push notifications enabled

This list comes from an article outlining Chrome's implementation which is updated periodically with new information about this subject.

like image 35
Besworks Avatar answered Sep 20 '22 20:09

Besworks