admin管理员组文章数量:1296921
Is it possible for a 3rd party script to write cookies to the user's puter?
For example, if affiliate.example
includes:
<script type="text/javascript" src=".js"></script>
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.
Is it possible for a 3rd party script to write cookies to the user's puter?
For example, if affiliate.example
includes:
<script type="text/javascript" src="http://me.example./cookiemonster.js"></script>
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.
Share edited Jul 17, 2019 at 21:29 Michael e lately 9,4228 gold badges68 silver badges94 bronze badges asked Oct 5, 2012 at 13:32 user1037355user10373552 Answers
Reset to default 7Yes, third party scripts can write cookies, and they will appear to belong to the domain of the page itself.
You can see this if you examine the cookies of any site using Google Analytics - the content es from a third party (Google) but the _utm
prefix cookies will be on the hosting site's domain.
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.
What happenned when you tested it?
(yes, if the browser/user permits, it will record a cookie - but the domain of the cookie is determined by the domain the script was loaded from).
本文标签: javascriptCan a 3rd party js script write cookiesStack Overflow
版权声明:本文标题:javascript - Can a 3rd party js script write cookies? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741626767a2389127.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论