简体   繁体   English

Session cookie 未从万神殿保存

[英]Session cookie is not getting saved from Pantheon

We are working on log in functionality with headless React and Pantheon with REST web services.我们正在使用 REST web 服务开发无头 React 和 Pantheon 的登录功能。 When I send login request to Drupal site in localhost, it sets a session cookie in my browser.当我向本地主机中的 Drupal 站点发送登录请求时,它会在我的浏览器中设置一个 session cookie。 However, it doesn't do that for Drupal site deployed to Pantheon.但是,它不会为部署到 Pantheon 的 Drupal 站点执行此操作。

The cookie:饼干:

set-cookie: SSESS4ca8b3ff629fc50c99bed7678686=VYfXzM-S18y0n8PylU9HuHBVrEyZezRiwfirxB%2ClL; expires=Fri, 18-Nov-2022 18:14:03 GMT; Max-Age=2000000; path=/; domain=.oursitename.pantheonsite.io; secure; HttpOnly

Login request:登录请求:

const body = {
      name: name,
      pass: pass,
    };
    const config = {
      headers: {
        "Content-Type": "application/json",
        "X-CSRF-Token": token,
      },
      withCredentials: true,
    };
    axios
      .post(
        `${process.env.REACT_APP_DRUPAL_URL}/user/login?_format=json`,
        body,
        config
      )

Update:更新:

Cookie is getting stored in Mozilla browser, but not in Chrome. Cookie 存储在 Mozilla 浏览器中,但不存储在 Chrome 中。

You need to append STYXKEY to the cookie's name.您需要 append STYXKEY到 cookie 的名称。 Cookies without that prefix are stripped from the request at the edge in Pantheon没有该前缀的 Cookies 将从万神殿边缘的请求中删除

You may find interesting as well this official documentation about pantheon and cookies您可能还会发现有关万神殿和 cookies 的官方文档也很有趣

https://pantheon.io/docs/cookies https://pantheon.io/docs/cookies

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM