读取不同主机的Cookie [英] Reading cookies across different hosts

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

问题描述

我有两个网站 - 两个都是我的项目。在现场二,我需要检查用户是否在网站一登录。我想这样做我应该创建一个脚本,将cookie放入iframe的主体,然后读取iframe的内容在网站二。但我不能。

I have two sites - both are my projects. On site two, I need to check if the user is logged in on site one. I suppose to do this I should just create a script that puts a cookie into the body of an iframe and then read the iframe contents on site two. But I can't.

以下是我为测试目的所做的代码:

http://jsbin.com/oqaza/edit

Here is a code I made for testing purposes:
http://jsbin.com/oqaza/edit

我遇到一个错误,说:



的许可被拒绝< http:// jsbin.com >获取属性
HTMLDocument.nodeType from
< http:/ /www.google.com >。


推荐答案

。通常有解决方案像OpenID(甚至在这里使用SO),但我发现,JSONP是最简单的方式读取跨域的Cookie:)

I finally got it. Generally there is solution like "OpenID" (used even here on SO), but I discovered, that JSONP is easiest way to read cookies across domain :)

这篇关于读取不同主机的Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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