JavaScript解决方案来检测是否禁用第三方Cookie [英] JavaScript solution to detect if third party cookie is disabled

查看:1323
本文介绍了JavaScript解决方案来检测是否禁用第三方Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的最终要求是检测是否为客户端浏览器启用了第三方,因为我的付款网关对于已停用第三方Cookie的浏览器有不同的方案。

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.

我尝试在我的页面内的iframe中设置Google Cookie,如下所示:

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>

,可以从Google创建第三方Cookie。

and was able to create third party cookies from google.

但我需要确认真的可以读第三方cookie吗?因为这样我可以确认客户端浏览器启用了第三方cookie,因为我可以读取google WAS ABLE创建的cookie。

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.

推荐答案

p>您无法从其他网站读取Cookie。如果可以,那么您可以从Google获取我的登录Cookie。这将是一个可怕的安全问题。

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.

您可以做的是确保第三方Cookie由您控制的网站设置,然后在网站之间进行通信,以指示已成功设置(例如,虽然 postMessage API )。

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).

这篇关于JavaScript解决方案来检测是否禁用第三方Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆