是否可以读取访客的cookie?
AdSense 使用 javascript 捕获当前页面的关键字来显示相关广告。但我最近注意到它也会显示与我的浏览历史记录相关的广告。看来javascript代码可以读取我的cookie(一般来说,我的意思是,例如访问的域列表)以显示相关广告。
实际上可以读取访问者的cookie吗?
AdSense use javascript to catch the keywords of current page to display relevant ads. But I was recently noticed that it will show ads related to my browsing history too. It seems that the javascript code can read my cookie (in general I mean, e.g. list of domains visited) to display relevant ads.
Is it practically possible to read cookies of a visitor?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不可以,由于同源政策,无法直接执行此操作。 (如果可能的话,那么您可以创建一个页面来窃取任何域中任何人的会话!)
但是,许多网站在其页面上包含来自广告提供商(请阅读 Google)的代码,以便 Google 知道您访问过网站X 因为网站 X 允许 Google 代码在有人访问时运行。当您稍后访问网站 Y 并要求 Google 代表其显示一些广告时,发生的情况并不神秘。
谷歌知道一切。
No, it isn't possible to do so directly due to the same origin policy. (If it were possible, then you could make a page that stole the session of anyone on any domain!)
However, many websites include code from ad providers (read Google) on their page -- so that Google knows that you have visited website X because website X allows Google code to run when someone visits it. When you later visit website Y and it asks Google to display some ads on its behalf, what happens is no mystery.
Google knows all.