Session not restored

I have the following scenario

File1.php starts the session and sets $_SESSION['foo'] = 'Hello';

File2.php starts the session and uses $_SESSION['foo'] without problems

File3.php starts the session and uses $_SESSION['foo'] without problems Within the output produced by File3 is the following:

<img id="graph" src="Graph.php" alt="Graph" />

Now when the Graph.php file runs, it starts the session but $_SESSION['foo'] does not exists.

After that, if I refresh File3, $_SESSION['foo'] is not there anymore.

Same thing if I go back to File2, $_SESSION['foo'] is lost.

I pinned point the problem down to the very line session_start() in Graph.php. If I completely empty Graph.php and just put the session_start() line in it, the problem occurs. If I remove the session_start() still with empty file, the problem goes.

I'm really puzzled. Can someone assist ?

Thanks.


It sounds like your Graph.php is over-writing the session cookie with a new, empty, session. Is there code that's included at the beginning of "normal" PHP files which you have skipped in Graph.php? It could be that you are using ini_set to change some of the session options (such as the session file directory, 'session.save_path' ) in this skipped startup code.

链接地址: http://www.djcxy.com/p/60234.html

上一篇: SESSION)无法在远程服务器上工作

下一篇: 会话未恢复