node.js - 在跨源请求中将域设置为客户端主机的 cookie
问题描述
当从 example1.com 到 example2.com 进行 api 调用时,服务器(example2.com)是否可以将 cookie 设置为域为“example1.com”的客户端(example1.com)
解决方案
我认为不可能将 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");
?>
更多访问:
关于类似主题的讨论很好。
推荐阅读
- python-3.x - 使用 Pyglet - Python 循环播放声音文件?
- flutter - 如何基于字符在 Flutter 中换行文本(不中断空格或“-”)?
- java - 安装 JavaFX 时遇到问题
- c++ - 如何使用 libusb c++ 从设备获取报告描述符
- python - 如何将 MainWindow 类的值传递给 DockWidget 的类
- pine-script - 如何仅显示某些绘制线的最新实例?
- karate - 将 XML 参数传递给 REST 端点
- html - 如何删除单词CSS之间的空格
- r - 将 R visNetwork HTML 从 RMarkdown 插入 SharePoint?
- javascript - HTML 在多个无序列表之间拖放