简体   繁体   English

在Chrome和IE的iFrame中丢失PHP会话

[英]Losing PHP sessions in iFrame with Chrome & IE

Question: 题:

I am having issues passing session variables from parent page to iFrame page and AJAX called PHP files in Chrome & IE. 我在将会话变量从父页面传递到iFrame页面和在Chrome&IE中称为PHP文件的AJAX时遇到问题。 It seems to work in FF and Safari though. 它似乎可以在FF和Safari中使用。

Environment: 环境:

I have Wordpress as my "Portal". 我将Wordpress作为我的“门户”。 One of my Wordpress pages is a "Dashboard". 我的Wordpress页面之一是“仪表板”。 That Dashboard makes AJAX requests against a CRM web service to render JSON data. 该仪表板针对CRM Web服务发出AJAX请求以呈现JSON数据。 Wordpress, the Dashboard file and the CRM are all on the same domain. WordPress,仪表板文件和CRM都在同一个域中。 "www.domain.com/wordpress" is the Wordpress domain, "www.domain.com/dashboard/dashboard.php" is the Dashboard file which is included via iFrame on a Wordpress page, and "www.domain.com/CRM/webservice.php" is the web service file I'm making AJAX calls against. “ www.domain.com/wordpress”是Wordpress域,“ www.domain.com/dashboard/dashboard.php”是Dashboard文件,该文件通过iFrame包含在Wordpress页面上,而“ www.domain.com/CRM” /webservice.php”是我正在对其进行AJAX调用的Web服务文件。

Approach: 方法:

User logs into Wordpress using LDAP. 用户使用LDAP登录到Wordpress。 I grab the username from Wordpress and dump it into a $_SESSION['WPUsername'] variable as an extension to Wordpress' login function. 我从Wordpress获取用户名,并将其转储到$_SESSION['WPUsername']变量中,作为对Wordpress登录功能的扩展。 Then, when my Dashboard loads in the iFrame, it makes a request to my CRM web service file via jQuery $.get() . 然后,当仪表板加载到iFrame中时,它将通过jQuery $.get()向我的CRM Web服务文件发出请求。 The webservice.php receives the request, then uses the $_SESSION['WPUsername'] session variable to internally query the appropriate data and return the response. webservice.php接收请求,然后使用$_SESSION['WPUsername']会话变量在内部查询适当的数据并返回响应。

Problem: 问题:

Firefox is working fine. Firefox运行正常。 IE & Chrome seem to think the $_SESSION['WPUsername'] doesn't exist when requested by webservice.php . webservice.php请求时,IE和Chrome似乎认为$_SESSION['WPUsername']不存在。

What am I missing? 我想念什么?

I made all of the recommended changes to my PHP configuration and website. 我对我的PHP配置和网站进行了所有建议的更改。 I set the cookie path in php.ini to "/" and I used the full subdomain path ("www.domain.com/dashboard/dashboard.php") in my iFrames. 我将php.ini中的cookie路径设置为“ /”,并在iFrame中使用了完整的子域路径(“ www.domain.com/dashboard/dashboard.php”)。 It seems to be working fine now. 现在看来一切正常。

On another note, I just implemented SSO using OpenAM as the IdP and SimpleSAMLphp as the SP. 另外,我只是使用OpenAM作为IdP和SimpleSAMLphp作为SP来实现SSO。 No need for session cookies to manage authentication anymore and all data passed between components is now done using web services. 不再需要会话cookie来管理身份验证,并且组件之间传递的所有数据现在都可以使用Web服务完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM