电话GAP SessionStorage [英] Phone GAP SessionStorage
本文介绍了电话GAP SessionStorage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用手机GAP在iPhone应用程序上工作。在我的应用程序,我们使用外部数据库。用户登录使用Web服务,我需要存储用户ID登录后。我存储用户ID使用手机GAP.can i使用手机GAP会话存储可以吗?
I working on an iPhone Application using phone GAP.In my app we are using an external DB .User login using web service, i need to store user ID after login .How i store the user ID using phone GAP.can i use phone GAP Session Storage for this?is possible?
任何人都知道请帮助。
谢谢,
Companion。
Thanks, Companion.
推荐答案
在Phonegap中你真的没有session的概念 - 你有HTML5 localStorage存储持久数据(认为应用范围):
You really don't have the concept of "session" in Phonegap - you have HTML5 localStorage to store persistent data (think "application scope"):
var userId = localStorage.getItem("userId");
if (userId==null || userId==0) {
jQT.goTo("#login");
}
登录用户:
$('#btnLogin').click(function(){
$("#loginFailure").hide();
$.getJSON(svcUri + "authenticate.cfm?username="+$("#username").val()+"&password="+$("#password").val() + "&callback=?",function(data) {
localStorage.setItem("userId",data.userid);
userId = data.userid;
if (data.userid != 0) {
// do some tasks after logging in
jQT.goTo('#travelz');
} else {
$("#loginFailure").show();
}
});
return false;
});
这篇关于电话GAP SessionStorage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文