1. <legend id='5Wfae'><style id='5Wfae'><dir id='5Wfae'><q id='5Wfae'></q></dir></style></legend>
    <i id='5Wfae'><tr id='5Wfae'><dt id='5Wfae'><q id='5Wfae'><span id='5Wfae'><b id='5Wfae'><form id='5Wfae'><ins id='5Wfae'></ins><ul id='5Wfae'></ul><sub id='5Wfae'></sub></form><legend id='5Wfae'></legend><bdo id='5Wfae'><pre id='5Wfae'><center id='5Wfae'></center></pre></bdo></b><th id='5Wfae'></th></span></q></dt></tr></i><div id='5Wfae'><tfoot id='5Wfae'></tfoot><dl id='5Wfae'><fieldset id='5Wfae'></fieldset></dl></div>

        <bdo id='5Wfae'></bdo><ul id='5Wfae'></ul>
    1. <small id='5Wfae'></small><noframes id='5Wfae'>

      <tfoot id='5Wfae'></tfoot>

    2. 未收到带有 axios 发布请求的 Set-Cookie 标头

      Not Receiving Set-Cookie Header with axios post request(未收到带有 axios 发布请求的 Set-Cookie 标头)

        • <bdo id='KAD3G'></bdo><ul id='KAD3G'></ul>

          <small id='KAD3G'></small><noframes id='KAD3G'>

        • <legend id='KAD3G'><style id='KAD3G'><dir id='KAD3G'><q id='KAD3G'></q></dir></style></legend>
          <tfoot id='KAD3G'></tfoot>

              <tbody id='KAD3G'></tbody>
          1. <i id='KAD3G'><tr id='KAD3G'><dt id='KAD3G'><q id='KAD3G'><span id='KAD3G'><b id='KAD3G'><form id='KAD3G'><ins id='KAD3G'></ins><ul id='KAD3G'></ul><sub id='KAD3G'></sub></form><legend id='KAD3G'></legend><bdo id='KAD3G'><pre id='KAD3G'><center id='KAD3G'></center></pre></bdo></b><th id='KAD3G'></th></span></q></dt></tr></i><div id='KAD3G'><tfoot id='KAD3G'></tfoot><dl id='KAD3G'><fieldset id='KAD3G'></fieldset></dl></div>

                本文介绍了未收到带有 axios 发布请求的 Set-Cookie 标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个 PHP 脚本,如果直接在浏览器中(或由邮递员)调用,它会成功返回一些简单的标头以及 set-cookie 标头.我可以从 chrome devTools 读取这样的响应头.但是一旦我通过 Axios 调用它,set-cookie 标头就不会出现,并且浏览器中也没有保存 cookie.

                I have a PHP Script which successfully returns some simple Headers as well as a set-cookie header if called directly in the browser (or by postman). I can read the response-headers like that from chrome devTools. But as soon as I call it by Axios, the set-cookie header doesn't show up and there's no cookie saved in the browser.

                我尝试了不同的方法,例如更改服务器端的响应标头并将withCredentials: true"与 axios 结合使用,但没有任何效果.我什至没有收到错误或任何与 cors 相关的问题.

                I tried diffrent things like changing the response-headers server-side and using "withCredentials: true" with axios, but nothing worked. I don't even get an error or any cors-related problems.

                PHP:

                header("Access-Control-Allow-Origin: http://localhost:8080");
                header("Content-Type: application/json; charset=UTF-8");
                header("Access-Control-Allow-Methods: POST, GET");
                header("Access-Control-Allow-Credentials: true");
                header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
                header("Access-Control-Max-Age: 99999999");
                setcookie("TestCookie", "Testing", time() + 3600, "/", "localhost", 0);
                die();
                

                JS:

                Vue.prototype.$http = axios.create({
                    baseURL: XYZ,
                    withCredentials: true
                })
                

                所以我的第一个问题是为什么直接调用php脚本时会出现header?以及如何存档以通过 axios 获取标题?

                So my first question is why does the header appear when calling the php script directly? And how can I archive to get the header through axios too?

                推荐答案

                可能 cookie 是 'httpOnly',这意味着客户端 javascript 无法读取它.因此它没有显示在 chrome cookie 部分.在 mozilla 中测试相同的请求,将显示标题.

                probably cookie is 'httpOnly', which means client side javascript can not read it. Therefore it is not showing in chrome cookie section. test the same request in mozilla, header will show up.

                这篇关于未收到带有 axios 发布请求的 Set-Cookie 标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                <legend id='34MwF'><style id='34MwF'><dir id='34MwF'><q id='34MwF'></q></dir></style></legend>

                1. <i id='34MwF'><tr id='34MwF'><dt id='34MwF'><q id='34MwF'><span id='34MwF'><b id='34MwF'><form id='34MwF'><ins id='34MwF'></ins><ul id='34MwF'></ul><sub id='34MwF'></sub></form><legend id='34MwF'></legend><bdo id='34MwF'><pre id='34MwF'><center id='34MwF'></center></pre></bdo></b><th id='34MwF'></th></span></q></dt></tr></i><div id='34MwF'><tfoot id='34MwF'></tfoot><dl id='34MwF'><fieldset id='34MwF'></fieldset></dl></div>
                    <tbody id='34MwF'></tbody>
                  • <tfoot id='34MwF'></tfoot>

                      <small id='34MwF'></small><noframes id='34MwF'>

                      • <bdo id='34MwF'></bdo><ul id='34MwF'></ul>