第三方js脚本可以写cookie吗?

第三方js脚本可以写cookie吗?

问题描述:

第三方脚本是否可以将cookie写入用户的计算机?

Is it possible for a 3rd party script to write cookies to the user's computer?

例如,如果 affiliate.example.org 包括:

<script type="text/javascript" src="http://me.example.com/cookiemonster.js"></script>

我想为会员提供脚本,以期在他们客户的计算机上写一个cookie;理想情况下,我们希望自己控制脚​​本。但是,在尝试此操作之前,我只是想看看是否有可能。

I want to provide an affiliate with a script, to hopefully write a cookie on their clients' machines; ideally we would want to control the script ourselves. However, before trying this, I just thought I would see if it is even possible.

当然,另一种选择是让我们为程序提供实际的脚本。

Of course, the other option would be for us to provide the actual script for the affiliate to put directly onto their site.

是的,第三方脚本可以编写cookie,并且它们似乎属于页面本身的域。

Yes, third party scripts can write cookies, and they will appear to belong to the domain of the page itself.

如果您使用Google Analytics(分析)检查任何网站的Cookie,就会看到此内容-内容来自第三方(Google),但 _utm 前缀cookie将在托管站点的域上。

You can see this if you examine the cookies of any site using Google Analytics - the content comes from a third party (Google) but the _utm prefix cookies will be on the hosting site's domain.

编写第三方cookie(即cookie所在的位置) (在第三方的域上)要求将Cookie发送到该第三方的下载标题中,而不是由JS代码编写。

To write third-party cookies (i.e. where the cookie is on the domain of the third party) requires that the cookies be sent in the headers of a download from that third party, and not written by JS code.