I have a PHP Session variable set:
$_SESSION['token']=$_POST['token']; on newOrder.php.
Also set is $_SESSION['orderId'], $_SESSION['stylesUrl'], $_SESSION['brand'] and $_SESSION['currentBalance']
There is a link on newOrder.php to templateSelection.php (same server).
At the bottom of newOrder.php I do a print_r($_SESSION) with the following output:
[token] => {61424637-6E77-BCE0-A10B-3F3E9F74753E}
[currentBalance] => 991.0000
[stylesUrl] => /Management/Stylesheets/basic.css
[brand] => YM
[savedOrderReturnURL] => /Management/DirectMail/DirectMailSaveOrder.aspx
This is directly at the bottom of the newOrder.php page with just two lines of HTML afterwards. When a user clicks a link to templateSelection.php the following php is processed:
<?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();
}
Inside php/db.php is:
$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();
Now this is the weird part. In firefox and chrome, the print_r in templateSelection.php outputs:
[token] =>
[currentBalance] => 991.0000
[stylesUrl] => /Stylesheets/basic.css
[brand] => YM
[savedOrderReturnURL] => /Management/DirectMail/DirectMailSaveOrder.aspx
However in Opera and IE9/8/7/6 it outputs
[token] => {61424637-6E77-BCE0-A10B-3F3E9F74753E}
[currentBalance] => 991.0000
[stylesUrl] => /Management/Stylesheets/basic.css
[brand] => YM
[savedOrderReturnURL] => /Management/DirectMail/DirectMailSaveOrder.aspx
session_start is always set, I have tried on multiple computers… it just makes no sense! This has also worked before on a different URL, on the same server.
As @Griwes suggests, you need to call
session_start()at the top of your script.