问题描述
我以一种安静的方式制作网络应用程序。
对于我的客户端我使用angularJs,相同的托管在 - 让说 -
i'm making a web app in a restful way.For my client side i'm using angularJs, the same is hosted at - lets say -https://domain.com
我的后端是建立在弹簧启动的基础上,我调用子域的所有资源 - 让我们说 -
My backend is built on spring boot and i call all the resources from a subdomain - lets say -https://xyz.domain.com
现在,当用户登录in,后端会向客户端发送一个http only cookie。
我可以在响应头中看到cookie,但是它没有在浏览器cookie中设置。
Now when a user logs in , the backend sends an http only cookie to the client.I can see the cookie in response header but its not being set in the browsers cookie.
经过一番研究,我尝试发送cookie与域= .domain.com
但是没有工作。
After a bit of research, i have tried sending cookie with domain = .domain.combut that didnt work either.
有一种方法,我可以为我的客户端在domain.com设置来自xyz.domain.com的cookie
Is there a way i can set cookie coming from xyz.domain.com for my client side at domain.com
(注意 - 我没有使用www.domain.com)
(Note - i'm not using www.domain.com )
任何帮助或线索都会很棒。
Any help or clue would be great.
感谢您回答我的问题。
Thank you for going through my question.
推荐答案
您描述的问题与跨网域Cookie政策有关。我不知道你的确切用法,但看看 CORS
和 P3P
标题应该给你一个好的开始。您可以选择通过Javascript手动设置Cookie。
The problem you're describing is related to cross domain cookie policies. I don't know your exact use-case, but looking at CORS
and P3P
headers should give you a good start. As an option, you can try setting your cookie manually via Javascript.
这篇关于设置子域的Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!