[PhoneGap] [Android] Store user and password

478 views
Skip to first unread message

Wonderm00n

unread,
Apr 17, 2010, 2:43:42 PM4/17/10
to phonegap
The app I'm developing uses email and password on the first screen.

The data is then validated trough Ajax to my PHP server.

What approach do you think it's better to save the email and pass
locally for future usage, if the user wants to, off course?

- HTML5 Web Storage / Database?
- Cookies (is this even possible with phonegap?)
- Any other options?

Don't forget I just want to store 2 simple strings...

--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com

Wonderm00n

unread,
Apr 18, 2010, 4:08:15 AM4/18/10
to phonegap
I received an email answer to this post:

"Cookies work well; limited to 4k.... HTML5 storage isn't "standard"
on <2.0, PhoneGap has an SQLite implimentation, but was waaaaaaay more
fiddly than LocalStoragr last time I tried it on android1.6..."

But...

Cookies doesn't seems to be working on Phonegap apps.

I'm using this functions: http://www.quirksmode.org/js/cookies.html
Like this:

On successful login:
createCookie("user_email_cookie",user_email,365);
createCookie("user_password_cookie",user_password,365);

When loading the page on other session:
if (readCookie('user_email_cookie')!='' &&
readCookie('user_password_cookie')!='') {
$('#email').val(readCookie('user_email_cookie'));
$
('#password').val(readCookie('user_password_cookie'));
}

But I always get NULL from the readCookie function, so I'm guessing
cookies don't work at all with phonegap?

Anyone?

On Apr 17, 7:43 pm, Wonderm00n <wonderm...@gmail.com> wrote:
> The app I'm developing uses email and password on the first screen.
>
> The data is then validated trough Ajax to my PHP server.
>
> What approach do you think it's better to save the email and pass
> locally for future usage, if the user wants to, off course?
>
> - HTML5 Web Storage / Database?
> - Cookies (is this even possible with phonegap?)
> - Any other options?
>
> Don't forget I just want to store 2 simple strings...
>
> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group athttp://groups.google.com/group/phonegap?hl=en?hl=en

Wonderm00n

unread,
Apr 18, 2010, 4:20:38 AM4/18/10
to phonegap
BTW...

If after setting the cookie I do:

alert(readCookie("user_email_cookie"));
alert(readCookie("user_password_cookie"));

I get the values ok, but if i kill the app and open it up again, I
just get "null" from the readCookie function...

So, are cookies dying with the app?

Pierreuno

unread,
Apr 29, 2010, 6:36:32 PM4/29/10
to phonegap
So what is the method you finally used ?

I'm developing an android app with phonegap and I tried to store my
login/password in a cookie and it doesn't work.

delasare

unread,
Apr 30, 2010, 8:33:15 AM4/30/10
to phonegap
I've run into the same issue. I've tried Lawnchair but can't seem to
find the right adaptor to use. I was about to try cookies. Can anyone
offer insight on the best way to approach storing user/pass on
Android? Here is my thread about my problems with both DOM storage and
Lawnchair. Any help or direction will be greatly appreciated. I think
Lawnchair should work, but I can't seem to get it configured properly.

http://groups.google.com/group/phonegap/browse_thread/thread/eb8814019f60211d#

Wonderm00n

unread,
May 3, 2010, 8:43:35 AM5/3/10
to phonegap
I didn't... still stuck on this.

Anyone there has a simple solution for this?

On Apr 29, 11:36 pm, Pierreuno <phuna...@gmail.com> wrote:
> So what is the method you finally used ?
>
> I'm developing an android app with phonegap and I tried to store my
> login/password in a cookie and it doesn't work.
>
> On Apr 18, 1:20 am,Wonderm00n<wonderm...@gmail.com> wrote:
>
>
>
> > BTW...
>
> > If after setting the cookie I do:
>
> > alert(readCookie("user_email_cookie"));
> > alert(readCookie("user_password_cookie"));
>
> > I get the values ok, but if i kill the app and open it up again, I
> > just get "null" from the readCookie function...
>
> > So, are cookies dying with the app?
>
> > On Apr 18, 9:08 am,Wonderm00n<wonderm...@gmail.com> wrote:
>
> > > I received an email answer to this post:
>
> > > "Cookies work well; limited to 4k.... HTML5 storage isn't "standard"
> > > on <2.0, PhoneGap has an SQLite implimentation, but was waaaaaaay more
> > > fiddly than LocalStoragr last time I tried it on android1.6..."
>
> > > But...
>
> > > Cookies doesn't seems to be working on Phonegap apps.
>
> > > I'm using this functions:http://www.quirksmode.org/js/cookies.html
> > > Like this:
>
> > > On successful login:
> > > createCookie("user_email_cookie",user_email,365);
> > > createCookie("user_password_cookie",user_password,365);
>
> > > When loading the page on other session:
> > > if (readCookie('user_email_cookie')!='' &&
> > > readCookie('user_password_cookie')!='') {
> > >                 $('#email').val(readCookie('user_email_cookie'));
> > >                 $
> > > ('#password').val(readCookie('user_password_cookie'));
>
> > > }
>
> > > But I always get NULL from the readCookie function, so I'm guessing
> > > cookies don't work at all with phonegap?
>
> > > Anyone?
>

Pierreuno

unread,
May 5, 2010, 12:44:40 PM5/5/10
to phonegap
Actually a cookie works fine for me.

So "document.cookie=" is the easiest solution.

Nicholas

unread,
May 5, 2010, 7:42:19 PM5/5/10
to phonegap
Does this method work for iPhone as well? I'm looking to accomplish
the same thing-- have an application that needs to remember a username/
password and persist it across requests. We are targeting Android and
iPhone for the app-- what's the best way to store this data? I started
looking into HTML5's SqlLite database stuff, but it doesn't seem to be
implemented on Android prior to 2.0. If the cookies do work across
Android 1.5+ and iPhone, that'd be great..

Pierreuno

unread,
May 6, 2010, 1:00:03 PM5/6/10
to phonegap
Cookies work on Android

Nicholas

unread,
May 6, 2010, 1:34:46 PM5/6/10
to phonegap
I understand that it works under Android, according to this thread,
but I was wondering if they work on iPhones the same way.
Reply all
Reply to author
Forward
0 new messages