How to store data on crossrider local database such that data persists till the browser is restarted/closed

StackOverflow https://stackoverflow.com/questions/15547638

Question

I have to store a 6 digit number on the crossrider local database, for which I am using appAPI.db.async .
I want to implement one of the following :
1) A way to tell crossrider to delete the data stored, when the browser is closed by the user. OR
2) A way to autoincrement the data when the browser is restarted next time.

Was it helpful?

Solution

The Crossrider DB API is persistent regardless of browser restarts.

Making a DB key expire on browser session end is not supported in our API and in general I'm not sure its even possible to be done with native extensions databases implementations. (this is more of a feature related to session cookies)

There is an alternate solution which is a sort of an hack: every time the user visits a page, the set the DB entry again to expire in 15 minutes (refreshing the built-in timer). So if they close their browser for 15 minutes, it will reset.

Don't forget you can set expiration times on the DB keys using this API: http://docs.crossrider.com/#!/api/appAPI.db-method-set

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top