在iframe 嵌入跨域网站时,session丢失问题其根源也是由于iframe跨站点cookie被阻导致session失效。如果两个站点都是相同的父域名就没有这个问题。
问题原因:
IE6/IE7支持的P3P(Platform for Privacy Preferences Project (P3P) specification)协议默认阻止第三方无隐私安全声明的cookie,Firefox目前还不支持P3P安全特性,firefox中自然也不存在此问题了。Mircosoft对此的具体描述可以参见 Privacy in Internet Explorer 6
解决方法:
A、Rails
before_filter :send_header
def send_header
response.headers['P3P'] = 'CP="CAO PSA OUR"'
end
B、IIS
1.打开IIS管理器 inetmgr
2.选择被嵌入iframe源站点或者目录,右键点击打开属性框
3.切换到HTTP头
4.添加
5.自定义HTTP头名: P3P
6.自定义HTTP头值: CP=”CAO PSA OUR”
7.关闭属性框退出,即刻生效
至于上面CAO PSA OUR的具体意思,请参考文章:Privacy in Internet Explorer 6
Rails and IFrames - Issues with Internet Explorer sessions
While using our new Share-It iframe for a project we came across a strange session issue with internet explorer that was tough to track down a solution to.
Basically we were loading an iframe with some parameters that were saved in a session, this worked fine on all browsers except for internet explorer.
Every request had a new session id, so the issue had to be with the cookies. As it turns out using an iframe from a different domain name is considered "third-party" and IE blocks the cookies unless....
You set this ( P3P compact policy ) response header.
P3P: CP="CAO PSA OUR"more details about the header and what it means can be found here.
you can easily do this in a controller using this call in a before filter with this line:
response.headers['P3P'] = 'CP="CAO PSA OUR"
Since the issue was harder to find a solution to than it should have been we decided it would make a good first development post from the Sympact team. Expect More...
分享到:
相关推荐
简介 Ruby On Rails 框架自它提出之日...Rails 是一个真正彻底的 MVC(Model-View-Controller) 框架,Rails 清楚地将你的模型的代码与你的控制器的应用逻辑从 View 代码中分离出来。Rails 开发人员很少或者可能从未遇到
Devise - 一个基于Warden的Rails灵活身份验证解决方案
rails_apps_composer, 一个 gem,为 Rails 启动应用程序创建 Rails 应用程序模板 Rails 应用编辑器 Rails 应用程序编辑器 gem 安装一个 命令行 工具来从"食谱"的Collection 组装 Rails 应用程序。"你可以使用 rails_...
使用Aptana+Rails开发Rails Web应用 有Aptana的安装配置等等,中文
activerecord-session_store, 从 Rails 中提取的记录存储的活动会话 Active Record 会话存储由 Active Record 类支持的会话存储。 提供了默认类,但是任何对 Active Record 会话类的对象鸭类型都有文本 session_id ...
webpack-rails, 将 web pack与你的Ruby on Rails 应用程序集成 不再维护webpack-rails 不再被维护。 有关详细信息,请参阅 #90. web pack-railsweb pack 为你提供了将 web pack集成到现有的Ruby on Rails 应用程序中...
Google Sign-In for Rails 实现将Google登录集成到您的Rails应用中
主要介绍了Rails应用程序中同时修改操作冲突问题的解决方案,本文讲解使用Rails 的 乐观锁解决这个问题并给出了代码救命,需要的朋友可以参考下
rails_layout, 为各种前端框架生成 Rails 应用程序布局文件 RailsLayout gem使用这里 gem 可以设置你选择的前端框架的布局文件:Zurb基础 5.3Bootstrap 4.0Bootstrap 3.3它还将为 Bootstrap 或者基础设置设计视图。...
karafka 基于Apache Kafka的Ruby和Rails应用程序开发框架
这是一个在Rails应用程序中使用React并使用webpack的示例
应用Rails进行REST开发.pdf Restful Rails Development
Rails Erd - 为Rails应用程序生成实体关系图
《应用Rails进行敏捷Web开发》中文第三版,找了很久才找到,介绍的是rails2.2.2
本章详细介绍Rails数据持久化技术ActiveRecord的使用,包括ORM与ActiveRecord的简介、建立数据表的映射、执行动态查询、插入数据、删除数据、表之间的关联,以及数据有效性验证等。 第11章 MVC的控制器层。本章...
meta-tags, 用于 Ruby on Rails 应用程序的搜索引擎优化( SEO ) 元标记:使你的Rails 应用程序搜索引擎友好的gem 用于 Ruby on Rails 应用程序的搜索引擎优化( SEO ) 插件。Rails 上的 rubyMetaTags主分支完全支持 ...
一个Rails应用程序,为DIY小型内容分发网络CDN提供支持
第二部分和第三部分与 Rails紧密联系,着重对Ruby这门语言进行详细介绍;所采用的Rails应用示例,既说明了Ruby的特性,也给出了有关Rails的重要信息。第四部分讲述了如何应用第二部分和第三部分的Ruby知识来开发...