拒绝将不安全标头"Cookie"设置为混合应用 [英] Refused to set Unsafe header "Cookie" Hybrid App

查看:133
本文介绍了拒绝将不安全标头"Cookie"设置为混合应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HTML5,CSS3,jQuery和cordova创建一个混合移动应用程序.

I am creating an hybrid mobile application using HTML5, CSS3, jQuery and cordova.

在由$.ajaxxhr.setRequestHeader调用servlet的应用程序中.代码如下;

In application calling an servlet by $.ajax with xhr.setRequestHeader. The code is below;

var userId = "testuser";
var userPin = "userpin";

var cookieData = "username=" + userId;

$.ajax({
   type: "POST",
   url: WEB_SERVICE_URL,
   data: {
        "EVENT_ID": "LOGIN",
        "userPin": userPin,
        "isHybrid": "H"
   },
   xhrFields: {withCredentials: true},
   beforeSend: function(xhr) {
        xhr.setRequestHeader("Cookie", cookieData);
   },
   success: function(response) {
        console.log(response);
        stopActivity();
   },
   error: function(err) {
        console.log(err);
        stopActivity();
   }
});

面对拒绝在控制台中设置不安全的标题"Cookie" 错误.未设置请求标头中的cookie.

Facing Refused to set unsafe header "Cookie" error in console. In request header cookie is not set.

如何在客户端解决问题?

How to resolve the issue in client side?

推荐答案

使用 cordova cookie主插件应该可以解决您的问题.该插件使您可以通过简单的界面从WebView获取和设置Cookie值. Android和iOS平台均支持此插件.

Using cordova cookie master plugin should resolve your issue. This plugin allows you to get and set cookie values from your WebView through a simple interface. This plugin is supported in both Android and iOS platforms.

这篇关于拒绝将不安全标头"Cookie"设置为混合应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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