I have a phonegap app for Android where is a login page, with the following code:
<h3>Log In</h3>
<input id="username" type="email" name="login" value="" placeholder="User" style="background: white;"/>
<input class="wrapped_input login_password" id="password" type="password" value="" name="password" placeholder="Password" style="background: white;"/>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<input type="checkbox" name="remember" id="remember" />
<label for="remember">Remember Password</label>
<input type="checkbox" name="mantener" id="mantener" disabled="disabled" />
<label for="keepIn">Keep me in</label>
</fieldset>
</div>
<div class="cta_button_wrapper">
<a href="javascript:login();" data-role="button" rel="external" data-transition="slide" data-theme="e" >Log</a>
</div>
In the login() function I do an Ajax call to a service and on success:
if($('#remember').is(':checked'))
{
setCookie("coreMobileLoginRemember", "true", 100);
setCookie("coreMobileLoginUser",user,100);
setCookie("coreMobileLoginHash",password,100);
if($('#mantener').is(':checked'))
setCookie("coreMobileLoginKeep", "true", 100);
else
deleteCookie("coreMobileLoginKeep");
}
else
{
deleteCookie("coreMobileLoginRemember");
deleteCookie("coreMobileLoginUser");
deleteCookie("coreMobileLoginHash");
deleteCookie("coreMobileLoginKeep");
}
In Android 2.2 it works fine, but in Android 4.0.3 the app doesn’t remember the user, I guess it’s something about the cookies, but I cannot figure what it is.
I solved this by using localStorage instead of cookies. If someone has an actual answer to this, please post it and I will accept it.