如何从重定向响应头读取cookie

时间:2022-08-23 10:32:57

I am having some authentication module, for authentication it goes on other domain with return url, and after login, again it redirect back to the original domain.

我有一些身份验证模块,对于身份验证,它使用返回URL在其他域上进行,并在登录后再次重定向回原始域。

How can i read the cookies from redirect response header ?

如何从重定向响应头读取cookie?

and i am using php and javascript and other domain is using ASP.net

我正在使用PHP和JavaScript和其他域使用ASP.net

Best Regards, AFFAN.

最诚挚的问候,AFFAN。

1 个解决方案

#1


0  

You can't.

The cookies are only communicated between the host that set them and the browser.

Cookie仅在设置它们的主机和浏览器之间进行通信。

The browser only exposes them to JS though document.cookies for the host that the HTML document was served from.

浏览器只通过document.cookies将它们公开给JS,以供提供HTML文档的主机使用。

Since you are getting a redirect instead of an HTML document, JavaScript will never see them.

由于您获得的是重定向而不是HTML文档,因此JavaScript永远不会看到它们。

#1


0  

You can't.

The cookies are only communicated between the host that set them and the browser.

Cookie仅在设置它们的主机和浏览器之间进行通信。

The browser only exposes them to JS though document.cookies for the host that the HTML document was served from.

浏览器只通过document.cookies将它们公开给JS,以供提供HTML文档的主机使用。

Since you are getting a redirect instead of an HTML document, JavaScript will never see them.

由于您获得的是重定向而不是HTML文档,因此JavaScript永远不会看到它们。