如何为所有网站设置 php 会话 cookie?

发布于 2024-09-19 04:50:01 字数 243 浏览 2 评论 0原文

我只对我的客户网站制作类似广告词的广告,并且我不想将 Cookie 保存到所有域(而不仅仅是域 mydomain.com 或子域 .mydomain.com,我的意思是全部)。

代码示例:
setcookie('var_name', 'var_value', null, "/", '.mydomain.com' );

有人可以帮助我吗?
谢谢

i'm making a adwords-like to my clients websites only, and i wan't to put the cookies to save the information to all domains (and not just domain mydomain.com or subdomains .mydomain.com, i mean all).

Code Sample:
setcookie('var_name', 'var_value', null, "/", '.mydomain.com' );

Can anybody help me?
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱本泡沫多脆弱 2024-09-26 04:50:01

您不能为外部域设置 cookie。这将是一个严重的安全缺陷。想象一下像会话固定这样的攻击是多么容易。

You cannot set a cookie for a foreign domain. That would be a serious security flaw. Just think of how easy attacks like session fixation would be.

秋风の叶未落 2024-09-26 04:50:01

您可以使用 iframe 在多个页面上为特定用户共享和显示相同的信息。这就是 Google Adsense 和许多其他广告解决方案的工作原理。

You can use an iframe to share and display the same information for a specific user on many pages. That's how Google Adsense and many other advertising solution work.

伪装你 2024-09-26 04:50:01

大多数此类跟踪系统的工作原理是将图像或其他对象嵌入到由您的域提供服务的参与站点中。此时,您可以从您控制的单个域发出 cookie,并通过查看 Web 请求上的推荐数据来跟踪用户。

由于该对象是从您的域提供的,因此不需要您所要求的跨域 cookie,这是幸运的,因为它们是不可能做到的。

Most tracking systems of this type work by embedding an image or some other object into participating sites which is served from your domain. At this point you can issue cookies from the single domain that you do control, and track the users by watching the referral data on your web requests.

Since the object is served from your domain, there's no need for the cross-domain cookies that you're asking for, which is fortunate because they're not possible to do.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文