Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular App-ionic:Chrome未在cors http请求中发送正确的cookie_Angular_Google Chrome_Http_Cookies_Ionic Framework - Fatal编程技术网

Angular App-ionic:Chrome未在cors http请求中发送正确的cookie

Angular App-ionic:Chrome未在cors http请求中发送正确的cookie,angular,google-chrome,http,cookies,ionic-framework,Angular,Google Chrome,Http,Cookies,Ionic Framework,我目前正在开发一个ionic应用程序,它使用http请求并使用cookie进行身份验证 首先,我登录: login(login, password): Observable<number>{ let body = new FormData(); body.append("pseudo", login); body.append("password", password); let url = this.baseUrl+"/service/login

我目前正在开发一个ionic应用程序,它使用http请求并使用cookie进行身份验证

首先,我登录:

login(login, password): Observable<number>{

    let body = new FormData();
    body.append("pseudo", login);
    body.append("password", password);

    let url = this.baseUrl+"/service/login";

    return Observable.create(observer => {

        this.http.post(url, body, this.options)
        .map(res => res.json())
        .subscribe(
            data => {
                // code omitted

            },
            err => {
                // code omitted
            }
        );
    });
}
然后我打另一个需要cookie的电话:

getUserInfos(): Observable<number>{

    let url = this.baseUrl+"/service/playerInfo";

    return Observable.create(observer => {
        this.http.get(url, this.options)
        .map(res => res.json())
        .subscribe(
            data => {
                // code omitted                 
            },
            err => {
                // code omitted
            }
        );
    });
}
我使用选项withCredentials:true,它是在此中设置的。选项构造如下:

this.headers = new Headers();
this.options = new RequestOptions({ headers: this.headers, withCredentials: true });
Firefox运行良好,发送了正确的cookie,一切正常。 有什么问题吗


非常感谢

请注意:这是服务器的配置问题。 cookie配置SameSite处于“严格”状态。
当我们将其更改为“无”时,一切正常。

感谢您发布答案@Linwe,你在哪里更改了SameSite配置?这是你在服务器上设置的头。这取决于服务器使用的技术。也许您可以在这里找到更多信息:
Accept:application/json, text/plain, */*
Accept-Encoding:gzip, deflate
Accept-Language:fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,la;q=0.6
Cache-Control:no-cache
Connection:keep-alive
Cookie:PHPSESSID=hmkgpm6hb10m9ldi7nm5vqnjq0; i18next=fr-FR
Host:www.jeuxpresto.com:2773
Origin:http://127.0.0.1:8100
Pragma:no-cache
Referer:http://127.0.0.1:8100/?ionicplatform=ios&ionicstatusbarpadding=true&http://127.0.0.1:8100/ionic-lab
User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36
this.headers = new Headers();
this.options = new RequestOptions({ headers: this.headers, withCredentials: true });