phonegap:基于 cookie 的身份验证 (PHP) 不起作用 [webview] [英] phonegap: cookie based authentication (PHP) not working [webview]

查看:30
本文介绍了phonegap:基于 cookie 的身份验证 (PHP) 不起作用 [webview]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用 sencha touch、HTML5 和 phonegap 作为包装器的移动网络应用程序.

I'm working on a mobile web-app using sencha touch, HTML5 and phonegap as a wrapper.

我正在使用 PHP 身份验证 (Cookie) 和 ajax 请求.在 safari 或 chrome 上一切正常,但在使用 phonegap (webview) 部署后,它不再工作了...

I'm using PHP-Authentication (Cookie) and ajax-requests. Everything works fine on safari or chrome, but after the deployment with phonegap (webview) it does't work anymore...

任何帮助将不胜感激:)

Any help would be appreciated :)

更多细节:

我的应用程序的所有数据都通过 ajax 请求加载到我的服务器组件mobile.php".我使用基本的 PHP-Auth 来验证用户:

All data for my app is loaded via ajax requests to my server component "mobile.php". I use basic PHP-Auth to autenticate the user:

  1. AJAX-Request [用户名,密码] -> mobile.php-> 会话建立(cookie)
  2. 所有其他请求(如果身份验证成功)

普通的 safari 网站和 webview 有什么区别?

What's the difference between a normal safari website and the webview?

推荐答案

我想通了:

您必须更改 phonegap_delegate.m 文件并将以下内容添加到 init 方法中:

you have to change the phonegap_delegate.m file and add the following to the init method:


- (id) init
{   
    /** If you need to do any extra app-specific initialization, you can do it here
     *  -jm
     **/
    //special setting to accept cookies via ajax-request
    NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage 
                                          sharedHTTPCookieStorage]; 
    [cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; 

    return [super init];
}

它使 webview 能够接受来自 ajax 请求的 cookie

it enables webview to accept cookies from ajax requests

这篇关于phonegap:基于 cookie 的身份验证 (PHP) 不起作用 [webview]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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