接受并记录外来cookie

发布于 2024-12-09 00:44:16 字数 351 浏览 1 评论 0原文

我正在尝试创建一个基于 PHP 的应用程序,让我学校的学生能够更清晰地展示他们的成绩。

我的目标是远程登录到他们的服务器并检索和格式化 XML。然而,他们的登录系统使用cookie。现在,我对 cookie 相当熟悉,但我很难找到一种方法来接受 cookie 并发送远程登录请求,该请求也发送系统设置的 cookie。

我尝试了几种连接方式:cURL、iFrames、AJAX,但似乎没有一种方式接受并记录/发送 cookie。

只需访问用户的网站而无需登录,cookie 就会添加到用户的浏览器中。我试图“捕获”标头信息,但我认为这是“cookie 嗅探”。

这是否可能,并且同源政策是否允许?

提前致谢!

I'm trying to create a PHP based application that allows students from my school to have a cleaner presentation of their grades.

My goal is to to remotely login to their server and retrieve and format the XML. However, their login system uses cookies. Now, I'm fairly familiar with cookies, but I'm having trouble finding a way to accept a cookie and send a remote login request that also sends the cookies set by their system.

I've tried a few ways of connecting: cURL, iFrames, AJAX, but none seem to accept and log/send the cookies.

The cookies are added to a user's browser just by visiting their site without logging in. I attempted to "catch" the header information, but I believe that's "cookie sniffing."

Is this even possible, and is it even allowed by the Same Origin policy?

Thanks in advance!

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

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

发布评论

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

评论(2

昵称有卵用 2024-12-16 00:44:16

我怀疑你将无法做你想做的事。如果您说您希望能够从他们的浏览器中获取 cookie 并将它们发送到您的 PHP 应用程序(位于不同的域),那么使用这些 cookie 远程​​登录到他们的应用程序,以便您可以转发信息从他们的服务器返回到你的服务器,那么不,绝对不是。同源的存在是为了避免这种事情的发生。

想象一下如果这可能的话。然后我可以编写一个 Web 应用程序来收集您的 Gmail cookie,并远程登录您的 Gmail 来执行我喜欢的任何操作。

如果我误解了您想要做什么,请告诉我,我会更新我的答案。

I suspect you will not be able to do what you want to do. If you are saying you want to be able to get the cookies out of their browser and have them sent to your PHP application (which is on a different domain) then use those cookies to log into their application remotely so that you can then relay info from their server back tot hem through yours, then no, definitely not. Same-origin exists explicitly to avoid that kind of stuff.

Imagine if that were possible. I could then write a web application that would harvest your gmail cookies, and log into your gmail remotely to do whatever I like.

If I am misunderstanding what you are trying to do, please let me know and I will update my answer.

林空鹿饮溪 2024-12-16 00:44:16

浏览器不会向您发送来自其他域的 cookie。如果您控制了两台服务器,那么您就可以管理某些内容,但由于您不这样做,您最接近的方法就是询问他们的凭据,如果他们提供了凭据,您就可以使用它。

虽然为什么他们会信任你......

The browser won't send you cookies from another domain. If you controlled both servers, you could then manage something, but as you don't the closest you could come would be to ask them for their credentials and if they supplied them, you could use that.

Although why they would trust you...

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