接受并记录外来cookie
我正在尝试创建一个基于 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我怀疑你将无法做你想做的事。如果您说您希望能够从他们的浏览器中获取 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.
浏览器不会向您发送来自其他域的 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...