Gecko / Webkit中的PHP会话取消设置

时间:2011-10-10 12:15:33

标签: php firefox session google-chrome

我有一个PHP Session变量集:

$_SESSION['token']=$_POST['token'];上的

newOrder.php

同时设置为$_SESSION['orderId']$_SESSION['stylesUrl']$_SESSION['brand']$_SESSION['currentBalance']

newOrder.phptemplateSelection.php(同一服务器)之间存在链接。

newOrder.php的底部,我使用以下输出执行print_r($_SESSION)

[token] => {61424637-6E77-BCE0-A10B-3F3E9F74753E}
[currentBalance] => 991.0000
[stylesUrl] => /Management/Stylesheets/basic.css
[brand] => YM
[savedOrderReturnURL] => /Management/DirectMail/DirectMailSaveOrder.aspx

这直接位于newOrder.php页面的底部,之后只有两行HTML。当用户单击指向templateSelection.php的链接时,将处理以下php:

<?php include("php/db.php");
header('P3P: CP="NOI ADM DEV COM NAV OUR STP"');
//$_SESSION['username']="bymtest";
//We seem to be getting an orderId in the session variable even though there wasn't one just before this page was called.
$debugMode = true;
if($debugMode) {
    echo "<pre>";
    print_r($_SESSION);
    echo "</pre>";
    die();
}

内部php/db.php是:

$dbhost = 'host';
$dbuser = 'un';
$dbpass = 'pw';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$db = mysql_select_db("db");
session_start();

现在这是奇怪的部分。在firefox和chrome中,print_r中的templateSelection.php输出:

[token] => 
[currentBalance] => 991.0000
[stylesUrl] => /Stylesheets/basic.css
[brand] => YM
[savedOrderReturnURL] => /Management/DirectMail/DirectMailSaveOrder.aspx

然而在Opera和IE9 / 8/7/6中它输出

[token] => {61424637-6E77-BCE0-A10B-3F3E9F74753E}
[currentBalance] => 991.0000
[stylesUrl] => /Management/Stylesheets/basic.css
[brand] => YM
[savedOrderReturnURL] => /Management/DirectMail/DirectMailSaveOrder.aspx
总是设置

session_start,我已尝试过多台计算机......这没有任何意义!这在以前在同一台服务器上的不同URL上也有效。

1 个答案:

答案 0 :(得分:0)

正如@Griwes建议的那样,您需要在脚本顶部调用session_start()