3

I am new to PhoneGap development. My PhoneGap application has a login page and I need to implement a "Remember Me" option into this login page. If the user has checked the "Remember Me" checkbox after entering username & password, the application should remember the user entered username & password and auto fill the information the next time the user launch the application (i.e. username & password should be persisted even when the application is closed, phone is restarted etc).

What is the best approach to implement this in a PhoneGap application..?

I know I can write the username and password to a file and read it back when app is launched. But I have a feeling that this is not the best way to do this due to various reasons including security.

Thanks in advance.

Bathiya Priyadarshana
  • 1,325
  • 6
  • 22
  • 35

1 Answers1

1

You can look into using an SQLLite database or LocalStorage, as documented here.

ToddBFisher
  • 11,370
  • 8
  • 38
  • 54
  • LocalStorage looks promising. Do you have an idea whether it is persistent or not..? By persistent I mean even when the application is closed or phone is restarted. Thanks.. – Bathiya Priyadarshana Dec 05 '11 at 06:58
  • 2
    yes, LocalStorage is persistent compared to SessionStorage, note thought to use encryption of some sort since LocalStorage is easily accessible by "wanna-be-hackers" [check my answer here](http://stackoverflow.com/questions/6238402/how-to-implement-a-first-time-only-login-scheme-for-a-mobile-web-application-imp/8308702#8308702) for a link to AES encryption jquery plugin – Leon Dec 05 '11 at 08:30
  • I got to work it with LocalStorage successfully. @Leon: The AES encryption plugin you mentioned looks cool. But one question. Once we incorporate that plugin, can we use the LocalStorage as same as without it from the Javascript side. I mean without worrying about that plugin and how it encrypts the LocalStorage, can we normally call the setItem() and getItem() methods on LocalStorage..? – Bathiya Priyadarshana Dec 05 '11 at 08:41
  • yes of course, but if it's encrypted you probably wont be able to make sense out of it ;-) – Leon Dec 05 '11 at 08:46
  • @Leon: Ok. So this means, if I use this AES plugin, when I store the username & password in LocalStorage by calling setItem() method, the values will be stored in an encrypted manner which is fine. And if I call the getItem() method the next time my app launches, it will return me some encrypted string for username & password..? – Bathiya Priyadarshana Dec 05 '11 at 08:53
  • you asked if you can still access it without using the plugin - I said yes, but if you use the AES plugin to also retrieve it then it will obviously decode it as well... – Leon Dec 05 '11 at 09:11
  • 1
    @Leon: Thanks for the input. I will try this out now that I have the LocalStorage to work properly. – Bathiya Priyadarshana Dec 05 '11 at 10:53