使用PhoneGap的Andr​​oid的饼干 [英] Android cookies using phonegap

查看:120
本文介绍了使用PhoneGap的Andr​​oid的饼干的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发出具有对用户名/密码,为记住我的信息复选框的文本框中输入用户登录页面PhoneGap的应用程序,以及一个提交按钮。

I have developed a phonegap application that has a user login page with a text box for username/password, a check box for "remember my info", and a submit button.

pretty标准。

当我在Firefox中打开它,cookie的正常工作,当被选中选中我的登录数据被记住。

When I open it in Firefox, the cookie works fine and my login data is remembered when the box is checked.

不过,使用Android模拟器的时候,我的cookie不会被保存,尽管navigator.cookieEnabled在模拟器上进行调试打印时返回true。

However, when using the android emulator, my cookie is not saved, despite "navigator.cookieEnabled" returning true when printed on the emulator for debugging.

如果需要,我可以张贴相关code,但我的问题是更普遍的:

I can post the relevant code if needed but my question is more general:

你怎么能存储使用PhoneGap的支持基于Web的语言在android系统编程饼干?它是类似于普通的网页JavaScript的饼干?难道还有比navigator.cookieEnabled以外的方法,将返回与否饼干为Android设备启用?

How can you store cookies in android programming using the web based languages that PhoneGap supports? Is it similar to normal web page javascript cookies? Is there a method other than "navigator.cookieEnabled" that will return whether or not cookies are enabled for the android device?

感谢。

推荐答案

有关移动应用开发HTML5具有本地存储和会话存储新功能。
同样喜欢饼干和会议Web开发

For mobile application development HTML5 has new feature for Local Store and Session Store. Same like cookies and session in web development

试着用 的localStorage 选项。我的工作只有这个办法。

Try with localStorage option. I worked this way only.

有关即存储在浏览器中存储在本地存储中值永久

For storing values in local storage i.e stored in browser permanently

window.localStorage.setItem("key", "Value");

有关在本地存储中获取价值。

For getting values in local storage

window.localStorage.getItem("Key")

有关手动删除本地存储的值

For manually remove values for local storage

window.localStorage.removeItem("Key")

如果你想管理会议你需要使用的sessionStorage 选项。

If you want to manage session you need to use sessionStorage option.

有关存储摧毁一旦移动应用程序关闭会话存储即值的值

For storing values in session storage i.e values destroyed once mobile apps closed

window.sessionStorage.setItem("key", "Value");

有关在会话存储获取值

window.sessionStorage.getItem("Key")

有关手动删除会话存储值

For manually remove values for session storage

window.sessionStorage.removeItem("Key")

这篇关于使用PhoneGap的Andr​​oid的饼干的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆