页面之间的PHP会话ID更改 [英] PHP Session Id changes between pages
问题描述
我有一个问题,我丢失了2页之间的PHP会话.
I have a problem where i am losing the PHP session between 2 pages.
session_start()包含在名为session-inc.php的文件中,该文件包含在每个需要设置会话的页面中.该功能适用于网站上的所有页面,但其中一个特定页面member-profile.php除外.当访问该页面时,将设置并使用具有不同ID(相同会话名称)的新会话.
The session_start() is included in a file called session-inc.php into every page requiring a session to be set. This works for all pages on the site except one particular page, member-profile.php. When this page is visited a new session with a different id (same session name) is set and used instead.
更多细节:
- 会话名称是手动设置的
- 所有页面都在同一域名下的同一服务器上
- 如果我在member-profile.php文件中的include('session-inc.php')上方放置了一个额外的session_start(),则该会话将正确进行
- 我尝试在.htaccess中设置session_cookie_domain和session.session_name,这对于该域有效,但是它阻止了会话被传递到付款域
- 我们正在用apache 5.2.6运行apache 2.2.6
将session_start()放在member-profile.php文件中include('session-inc.php')上方是解决此问题的快捷方法,但我想知道是否有人知道为什么会这样
Putting the session_start() above the include('session-inc.php') in the member-profile.php file is the quick and dirty fix for this problem, but i am wondering if anybody know why this would be happening.
欢呼
会
推荐答案
根据PHP文档, session_start
-该页面是否具有流氓CR/LF,Unicode字节序标记或类似的内容,导致您在
According to PHP documentation, session_start
must be called before any output is sent back to the browser-- could this page have a rogue CR/LF, Unicode byte-order mark or similar that is causing output before you include('session-inc.php')
?
这篇关于页面之间的PHP会话ID更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!