Felix O'Brien Felix O'Brien - 8 months ago 41
HTML Question

Saving variables to localstorage with Phonegap

I have a cookie clicker like app, and I'm up to the stage where I need to save the amount of cookies a user has locally. But because this is an ever changing variable, I'm having trouble doing it.

var cookies = 0;

How would I implement localstorage of this, because every time the var changes I end up with 0001 and similar results.


Cordova use regular webview so you can use localstorage like in a webkit browser.

Save value:

localStorage.setItem("cookies ", 1);

Read Value:

var cookies =localStorage.getItem("cookies");