问题
My ultimate requirement is to detect if third party is enabled for the client browser because my payment gateway has a different scenario for browsers with disabled third party cookies.
I tried setting up google cookies from within an iframe within my page as below:
<iframe src="http://www.google.com" frameborder="0" style="border:0; display:none;"></iframe>
and was able to create third party cookies from google.
But I need to confirm "Is it really possible to read third party cookie?" because this way I can confirm that client browser has third party cookie enabled because I could read the cookies which google WAS ABLE to create.
回答1:
You can't read cookies from other sites. If you could, then you could get my login cookie from Google. That would be a horrific security problem.
What you can do is make sure the third party cookie is set by a site that you control and then communicate between the sites to indicate that it was set successfully (e.g. though the postMessage API).
来源:https://stackoverflow.com/questions/22411226/javascript-solution-to-detect-if-third-party-cookie-is-disabled