使用php jquery从用户获取cookie?用于广告系统
我想建立自己的广告系统(就像您在网站上看到的那些横幅),我该怎么做?如何捕获用户访问过的cookie?
我知道如果我有 google adsense 或其他东西,它会向他们以前访问过的用户显示广告。它能够这样做的方式是因为它能够访问用户的cookie?我想知道如何使用 php 或 jquery 或 ajax 或其他东西来访问这些 cookie,就像那些广告一样?
有什么想法吗?
谢谢!
I want to build my own advertisement system (like those banners you seen on websites), how would I do so? How do I capture the cookies that the users have visited?
I know that if I had google adsense or something, it will display advertisements to users that they have previously visited. The way its able to do so is because its able to access cookies from the users? I was wondering how do I use php or jquery or ajax or something to access those cookies like those ads are?
Any thoughts?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
同源策略可防止任何站点获取其他站点设置的 cookie 或任何其他数据。无法知道用户访问了哪些其他网站,更不用说读取这些网站设置的 cookie。
只有“Referer”HTTP 标头会告诉您有关用户访问过的其他网站的信息,并且这只是一个网站,并且仅当它链接到您时才如此。
现在,您对 Adsense 的想法是 Adsense 能够了解您在其他网站上的行为。然而,Adsense 只能对具有 Adsense 代码的网站执行此操作,其中 Adsense 代码涉及从 Adsense 域设置 cookie 的 iframe 或图像。因此,从技术上讲,它并不能读取其他域设置的 cookie,也不能了解用户在其他网站上的行为,它只是在用户访问其他启用 Adsense 的网站时读回 Adsense 本身设置的 cookie。
The same-origin policy prevents any site from obtaining cookies or any other data set by other sites. There is no way of knowing which other sites a user has visited, let alone read the cookies set by those sites.
Only the "Referer" HTTP header will tell you about other sites the user has visited, and this will only be one site, and only if it linked to you.
Now, what you are thinking of with Adsense is that Adsense is able to know your behaviour on other sites. However, Adsense can only do that for sites which have Adsense code on them, where the Adsense code involves an iframe or image that sets a cookie from Adsense's domain. So it's not technically reading cookies set by other domains and it's not technically able to know a user's behaviour on other sites, it's just reading back cookies set by Adsense itself when the user visited other Adsense-enabled sites.