JavaScript solution to detect if third party cookie is disabled [duplicate]

喜夏-厌秋 提交于 2019-12-24 11:43:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!