简体   繁体   English

带有phonegap的jQuery-mobile在Android 4.0上未获取Cookie

[英]Jquery-mobile with phonegap not getting cookies on Android 4.0

I have a phonegap app for Android where is a login page, with the following code: 我有一个适用于Android的phonegap应用,其中是一个登录页面,其中包含以下代码:

<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: 在login()函数中,我对服务进行Ajax调用,并成功执行:

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. 在Android 2.2中,它运行良好,但在Android 4.0.3中,该应用程序不记得用户,我想这与Cookie有关,但我无法弄清楚它是什么。

I solved this by using localStorage instead of cookies. 我通过使用localStorage而非cookie解决了此问题。 If someone has an actual answer to this, please post it and I will accept it. 如果有人对此有实际答案,请发布并接受。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM