从不同的域读取 cookie [英] Reading a cookie from a different domain

查看:49
本文介绍了从不同的域读取 cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为公司内部的活动开发页面/表单.但是,第一步是检查此人是否已登录.这很容易根据 cookie - CUSTOMER 进行检查,该 cookie 在他们登录后设置.

I'm developing a page/form for a campaign inside my company. However, the first step is to check if the person is logged in. This is easily checked against a cookie - CUSTOMER - that is set once they're logged in.

然而:1)我在本地开发,不在同一个域上,结果看不到那个cookie2) 最终活动可能会也可能不会驻留在实际域中.他们最终可能会使用虚 URL 或其他内容.

However: 1) I'm developing locally, not on the same domain, and, as a result can't see that cookie 2) The final campaign may or may not end up residing on the actual domain. They may end up using a vanity URL or something.

为此,我们假设我无权访问设置 cookie 的主域.

For purposes of this, let's assume I do NOT have access to the main domain where the cookie was set.

如何从域外读取该 cookie?哦,既然 IT 人员不让我们接触后端grumble,那么它必须是一个 JS 解决方案.

How can I read that cookie from off the domain? Oh, and since IT folks don't let us touch the back-end grumble, it has to be a JS solution.

谢谢!

推荐答案

你不能.

您可以使用客户端 JavaScript 读取的唯一 cookie 是那些属于 HTML 文档宿主的 cookie,其中嵌入了

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆