Cross-domain carrying problem of cookie

currently I have an interface with the address a.com and the page requests b.com . Using CORS to cross-domain, the data is fine and can be returned normally, but how to pass cookie under a.com to b.com ? The request is using fetch , and credentials: "include" has been set, but it still has no effect. The header Cookie is not added to the browser request at all!

how to solve this cross-domain cookie delivery problem? Are there any great gods who have the experience to guide them?

Mar.03,2021

the conclusion is no, refer to an article and a question to discuss

This won't work if third-party cookies are disabled (automatic for some browser situations)

Cross-Domain Cookies


The

server needs to add the header Access-Control-Allow-Credentials: true , and specify the specific allowed domain names such as Access-Control-Allow-Origin: http://a.com.

js you need to add new XMLHttpRequest (). WithCredentials = true to the XMLHttpRequest object.

Menu