【问题标题】:Setting cookie with domain as client host in a cross origin request在跨源请求中将带有域的 cookie 设置为客户端主机
【发布时间】:2020-07-06 15:31:57
【问题描述】:

当从 example1.com 到 example2.com 进行 api 调用时,服务器(example2.com)能否将 cookie 设置为域为“example1.com”的客户端(example1.com)

【问题讨论】:

    标签: node.js xml cookies cross-domain


    【解决方案1】:

    我认为不可能将 cookie 从一个域设置到另一个域,因为如果发生这种情况,将会有很多安全漏洞。

    您需要获取 example2.com 来设置 cookie。如果 example1.com 将用户重定向到 example2.com/setcookie.php?example3=value

    setcookie 脚本可以包含以下内容来设置 cookie 并重定向到 example2.com 上的正确页面

    <?php
        setcookie('example1', $_GET['example3']);
        header("Location: example2.com/landingpage.php");
    ?>
    

    更多访问:

    https://stackoverflow.com/questions/6761415/how-to-set-a-cookie-for-another-domain#:~:text=Setting%20cookies%20for%20another%20domain,encode%20this%20into%20the%20url.&text=You%20can't%2C%20at%20least,be%20a%20nasty%20security%20risk.

    关于类似主题的讨论很好。

    【讨论】:

      猜你喜欢
      • 2018-02-27
      • 2015-12-21
      • 2011-10-21
      • 2013-12-02
      • 2013-04-12
      • 2014-09-05
      • 2021-01-16
      相关资源
      最近更新 更多