使用会话变量,饼干与PhoneGap的在iPhone和Android [英] Using Session variable and cookies with Phonegap on iPhone and Android

查看:124
本文介绍了使用会话变量,饼干与PhoneGap的在iPhone和Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题越来越PHP会话变量(如$ _SESSION [用户名])内,通过从PhoneGap的应用程序的Ajax调用PHP发起服务器端code正常工作。

I have had problems getting PHP session variables (e.g. $_SESSION['username']) to work within PHP server side code launched via an ajax call from a Phonegap app.

在研究此问题,我发现相互矛盾的意见,以决定是否不会话变量和Cookie都可以使用。

On researching this problem I have found conflicting advice as to whether or not session variables and cookies can be used.

有没有人有一个明确的答案?

Does anyone have a definitive answer?

如果会话变量和Cookie的使用是否有可能已经对他们贡献了不工作的任何问题,我应该知道使用它们?

If session variables and cookies can be used are there any issues I should be aware of in using them that may have contributed to them not working?

我知道,可以启用Cookie用于在iPhone上的PhoneGap的应用程序,但据我所知,没有为Android。

I know that cookies can be enabled for Phonegap apps on an iPhone but as far as I am aware not for Android.

推荐答案

您会好起来,你通常会存储在会话变量中的数据传递到通过JSON你的PhoneGap应用程序,并具有应用商店这种方式。

You would be better off passing the data you would normally store in the session variables to your PhoneGap app via JSON and having the app store it that way.

你可以把它像使用外部API。该应用程序将进行身份验证,并得到一个令牌。这将存储的令牌,并用它来进一步验证请求到服务器进行身份验证。

Think of it like using an external API. The app would authenticate and get back a token. It would store that token and use that to validate further requests to the server were authenticated.

这篇关于使用会话变量,饼干与PhoneGap的在iPhone和Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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