使用带饼干跨域JSONP请求? [英] Using cross domain JSONP requests with cookies?

查看:167
本文介绍了使用带饼干跨域JSONP请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的情况是这样的:

我用2域。

在DOMAIN1我的用户登录,并有一个会话cookie此域设置。

In domain1 my users are logged in and there is a session cookie set for this domain.

在域2在我的HTML我包括与URL指向该工程domain1并产生的JavaScript应用程序的脚本标记。像这样的:

In domain2 in my html I include a script tag with url pointing to an application that works on domain1 and which generates javascript. Like this:

<script src="http://domain1.com/jsactions"></script>

我不知道。当用户输入域2可我认为jsactions应用程序( http://domain1.com/jsactions )将永远免费获赠会议饼干这对于DOMAIN1设置? (假设ofcourse这是pviously创造$ P $)

I'm wondering. When users enter domain2 can I assume that jsactions app (http://domain1.com/jsactions) will always recieve session cookie that was set for domain1 ? (Assuming ofcourse that it was previously created)

我不知道将这项工作在IE8 +和最新的Firefox,Chrome和Safari浏览器。

I'm wondering will this work in IE8+ and recent Firefox, Chrome and Safari.

推荐答案

是的,我们最近测试了这种方法。该JSONP请求包含它的域的Cookie(域1中的情况下)。

Yes, we've tested this approach recently. The JSONP request contains it's domain cookies (domain1 in your case).

和越飞越 - 如果JSONP响应被设置在他的头一个Cookie - 该cookie将被纳入下一次往返。我们(不redirectiong到DOMAIN1在所有)实现跨域登录方案利用这种行为。

And more over - if the JSONP response is setting a cookie in his header - that cookie will be included in the next roundtrip. We achieved crossdomain login scenario leveraging this behaviour (without redirectiong to domain1 at all).

这篇关于使用带饼干跨域JSONP请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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