从axios本地请求获取cookie

时间:2019-11-18 12:34:43

标签: php cookies

我在服务器端(PHP)上接收cookie时遇到问题。 当我使用这些Axios requestheaders发送到服务器(local.project.com:8000)时,服务器将保存cookie并将其发送回前端Response cookies。那么当我发出另一个请求时,我并没有在PHP调试模式下取回cookie。但是当从POSTMAN发出相同的请求时,我确实在服务器端看到了cookie

正面:

res = await axios({
                method: 'post',
                url: url,
                async: false,
                data: qs.stringify(giParams),
                credentials: 'include',
                crossDomain: true,
                headers : {
                    "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
                 }
            });


返回:

        header('Access-Control-Allow-Origin:http://local.project.com:8080');
        header('Access-Control-Allow-Credentials:true');
        header('Content-Type: application/json');
        header('Cache-Control: public');
        $cookie = setcookie('sometest3', 'asdsadsadsadsad', time() + 86400, "/", 
        'local.project.com:8080' , false , true);
        Yii::app()->request->cookies[$cookieType] = $cookie;


有什么建议吗?

0 个答案:

没有答案