Page 1 of 2

Clear local storage when app closes

Posted: Tue Jun 03, 2014 7:37 am
by casey palmer

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.


Clear local storage when app closes

Posted: Tue Jun 03, 2014 8:04 am
by Evgene Karachevtsev

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.


Clear local storage when app closes

Posted: Wed Jun 04, 2014 5:32 am
by casey palmer

Worked great, Thanks.


Clear local storage when app closes

Posted: Wed Jul 16, 2014 2:38 pm
by Mike6580064

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


Clear local storage when app closes

Posted: Wed Jul 16, 2014 8:00 pm
by casey palmer

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??


Clear local storage when app closes

Posted: Thu Jul 17, 2014 12:13 am
by Alena Prykhodko

Casey,

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


Clear local storage when app closes

Posted: Thu Jul 17, 2014 5:18 am
by casey palmer

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


Clear local storage when app closes

Posted: Tue Jul 22, 2014 1:51 pm
by Mike6580064

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.


Clear local storage when app closes

Posted: Wed Jul 23, 2014 1:18 am
by Yurii Orishchuk

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.


Clear local storage when app closes

Posted: Wed Jul 23, 2014 8:41 am
by casey palmer

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/...