如何在称其为第三方时提供原点的第一方饼干

发布于 2025-01-28 01:31:43 字数 425 浏览 4 评论 0原文

假设我拥有一个网站“ cookiemaker.com”。我希望我的客户端(网站所有者本身)将HTTP请求发送到包括我生成的cookie的服务器。换句话说:

  1. 最终用户“鲍勃”访问了我的网站cookiemaker.com
  2. i(cookiemaker.com)为他提供了一个cookie,他的浏览器现在存储
  3. 鲍勃现在正在访问另一个网站(“ cool-recipes.com “)
  4. 鲍勃在cool-recipes.com中单击一个按钮,然后他的浏览器将http请求发送到cookiemaker.com

有没有办法将在(4)发送的请求中包括在(2)中创建的cookie?

(假设两个网站完全控制)

Suppose I own a website at "cookiemaker.com". I want my client (website owners themselves) to send HTTP requests to my server that include cookies I generated. In other words:

  1. End-User "Bob" visits my site at cookiemaker.com
  2. I (cookiemaker.com) provides him with a cookie that his browser now stores
  3. Bob is now visiting another website ("cool-recipes.com")
  4. Bob clicks a button within cool-recipes.com, then his browser sends an HTTP request to cookiemaker.com.

Is there a way to include the cookie created at (2) in the request sent at (4)?

(Assuming full control of both websites)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏末的微笑 2025-02-04 01:31:43

HTTP cookie始终发送到所请求的URL,请求它的来源(cool-recipes.com)应与标头的响应如下:

Access-Control-Allow-Origin: <origin> //The website requester

如果不存在此标头,您将获得一个错误如下:

Access to fetch at '<requested site>' from origin '<your site>' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

您必须将Origin(cool-recipes.com)添加到请求的响应标头(cookiemaker.com)。

Access-Control-Allow-Origin: https://cool-recipes.com

HTTP cookies are always sent to the url requested, the origin requesting it (cool-recipes.com) should have a response with a header as the following:

Access-Control-Allow-Origin: <origin> //The website requester

If this header is not present, you will get an error like the following:

Access to fetch at '<requested site>' from origin '<your site>' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

You have to add the origin (cool-recipes.com) to the site requested response headers (cookiemaker.com).

Access-Control-Allow-Origin: https://cool-recipes.com
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文