我有一个PHP Session变量集:
$_SESSION['token']=$_POST['token'];
上的 newOrder.php
。
同时设置为$_SESSION['orderId']
,$_SESSION['stylesUrl']
,$_SESSION['brand']
和$_SESSION['currentBalance']
newOrder.php
与templateSelection.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上也有效。
答案 0 :(得分:0)
正如@Griwes建议的那样,您需要在脚本顶部调用session_start()
。