Cookies - set across multiple domains

后端 未结 5 1621
梦如初夏
梦如初夏 2021-02-01 22:01

My company has a setup as follows:

  • subdomain1.domain1.com
  • subdomain2.domain1.com
  • subdomain3.domain1.com
  • subdomain4.domain1.com
5条回答
  •  旧时难觅i
    2021-02-01 22:23

    As stated by others, you can't access cookies across domains. However, if you have control of the server code, you can return information in the body, and allow your client to read and store that information per server.

    In my case, I'm connecting a single client to multiple servers, maintaining an authenticated connection to each one. I need to know when the session for each one is going to expire, so the authentication service returns the cookie, plus it modifies the body of the response to send the relevant data back, so that I can read that data and set my own cookies.

    By doing this, I can manually track what I need. Won't work in every scenario, but might for some like me.

提交回复
热议问题