casey palmer
Posts: 0
Joined: Tue Mar 18, 2014 6:32 am

Clear local storage when app closes

Hello,

Is it possible to dispose or clear all local storage items after a period of time, when the app closes or at log off? I am not sure this is very important to keep this data but I don't think it is harmful to keep, more of less was thinking about house cleaning.

Thanks.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Clear local storage when app closes

Hello Casey,

You can use JS code:

codelocalStorage.clear(); /code

to clear local storage item. Invoke this code on logout_service "success" event, for example.

casey palmer
Posts: 0
Joined: Tue Mar 18, 2014 6:32 am

Clear local storage when app closes

Worked great, Thanks.

Mike6580064
Posts: 0
Joined: Wed Jan 15, 2014 6:00 pm

Clear local storage when app closes

What if I don't use a logout service but want to clear local storage when the app is closed?

casey palmer
Posts: 0
Joined: Tue Mar 18, 2014 6:32 am

Clear local storage when app closes

Im not sure in Appery because I have not tried but could you use session storage if you want to clear storage when mobile browser is closed??

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Clear local storage when app closes

Casey,

Please read more about localStorage here http://devcenter.appery.io/documentat...

casey palmer
Posts: 0
Joined: Tue Mar 18, 2014 6:32 am

Clear local storage when app closes

Well looks like you can use Session Storage. Thanks for info.. Im just learning HTML5 so this is nice.

Mike6580064
Posts: 0
Joined: Wed Jan 15, 2014 6:00 pm

Clear local storage when app closes

Upon a successful login, I'm currently passing a response parameter "sessionToken" to a local storage variable "userSessionToken" via mapping. I don't have a logout service but I'd like to clear this local storage variable "userSessionToken" when the app is closed.

Casey, from the documentation on session storage it looks like this clears when the page is refreshed or navigated away from. I'm talking about on app exit only.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Clear local storage when app closes

Hi Mike,

Unfortunatly there is no "exit" event in phonegap(platform feature).

You can read about avaliable phone gap events here and make logic you need on this base.

http://docs.phonegap.com/en/2.0.0/cor...

For example you can try solution from following topic based on "resume" and "pause" events:

http://stackoverflow.com/questions/46...

Regards.

casey palmer
Posts: 0
Joined: Tue Mar 18, 2014 6:32 am

Clear local storage when app closes

okay got it.. If I happen to come across anything I will send it your way.. Good Luck.. Maybe you know this but there is an expiration on the session tokens. Session token lifetime is 120 minutes. Thereafter the key is not valid.

https://getsatisfaction.com/apperyio/...

Return to “Issues”