为什么PHP $ _SESSION不能在iFrame之间工作? [英] Why isn't PHP $_SESSION working between iFrames?

查看:210
本文介绍了为什么PHP $ _SESSION不能在iFrame之间工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我有一个页面,其中包含几个包含注册过程步骤的iFrame(一个是基本信息,另一个是教育等等)。无论如何,每个iFrame都会通过jQuery $ .post调用和PHP文件集合将新信息推送到mySQL服务器。因此,在一个iFrame中,信息被推送到PHP文件,然后将其发送到服务器然后存储用户在$ _SESSION [''userid'']变量中的ID。然后,我尝试在教育iFrame下回显这个相同的变量,看看它是否可以读取会话信息。但是,该值返回空白。经过一些研究,我意识到我需要包含一个session_start()函数,所以我在< HTML>之前将它放在我的父窗口中。标签。但是,它仍然无法正常工作。我希望你们能理解我......有什么建议吗?提前致谢。我做错了什么?

Okay, so I have a page that consists of several iFrames containing "steps" to a signup process (one is basic info, another education, etc..). Anyway, each iFrame pushes the new information to the mySQL server via jQuery $.post calls and a collection of PHP files.. So, in one iFrame, the information is pushed to a PHP file, which sends it to the server and then stores the user''s id in a $_SESSION[''userid''] variable. Then, I try echoing this same variable under the education iFrame to see if it can read the session info. However, the value returns blank. After some research, I realized I needed to include a session_start() function, so I stuck this in my parent window before the <HTML> tag. However, it''s still not working. I hope you guys can understand me... Any advice? Thanks in advance. What am I doing wrong?

推荐答案

.post调用和PHP文件的集合..因此,在一个iFrame中,信息被推送到PHP文件,将其发送到服务器,然后将用户的id存储在
.post calls and a collection of PHP files.. So, in one iFrame, the information is pushed to a PHP file, which sends it to the server and then stores the user''s id in a


_SESSION [''userid'']变量中。然后,我尝试在教育iFrame下回显这个相同的变量,看看它是否可以读取会话信息。但是,该值返回空白。经过一些研究,我意识到我需要包含一个session_start()函数,所以我在< HTML>之前将它放在我的父窗口中。标签。但是,它仍然无法正常工作。我希望你们能理解我......有什么建议吗?提前致谢。我做错了什么?
_SESSION[''userid''] variable. Then, I try echoing this same variable under the education iFrame to see if it can read the session info. However, the value returns blank. After some research, I realized I needed to include a session_start() function, so I stuck this in my parent window before the <HTML> tag. However, it''s still not working. I hope you guys can understand me... Any advice? Thanks in advance. What am I doing wrong?


IFRAME是一个html级别(客户端)元素(由于不推荐使用,因此不应使用)。无论如何,所有iframe都引用了一些php脚本。这就是你应该已经知道的。现在的教训:你必须在所有这些php脚本的开头包含 session_start(); ,包括你通过ajax调用的那个 - 无关紧要您尝试实施的工作流程。如果不存在,函数调用将启动一个新会话,并将脚本附加到现有会话。
The IFRAME is a html level (client side) element (that you should not use since it is deprecated). Anyway, all iframes refer to some php scripts. That is what you should have known already. Now the lesson: you have to include session_start(); at the beginning of all these php scripts, including the one you call via ajax - indifferent of the workflow you try to implement. The function call will start a new session if does not exist, and it is attaching your script to the existing one.


这篇关于为什么PHP $ _SESSION不能在iFrame之间工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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