There may be better ways of doing this, but I'm pretty sure I should still get my session_id() passed to the second page. Instead, calling this on page 2 as my first few lines generates a brand new session_id() than the one created on page 1.
PAGE 2 BEGINNING:
<?php
error_reporting(E_ALL);ini_set('display_errors',1);
session_start();
echo session_id();
$sessionid = session_id();
echo "sessionNUM          = $sessionid\n";
echo "<br>";
echo '<pre>' .print_r($_SESSION, TRUE) . '</pre>';
PAGE 1 ALL:
<?php
error_reporting(E_ALL);ini_set('display_errors',1);
session_start();
$sessionid = session_id();
$currentDate = date('Y-m-d');
//echo "sessionNUM          = $sessionid\n";
//echo "<br>";
//echo "<br>";
//echo '<pre>' .print_r($_SESSION, TRUE) . '</pre>';
session_unset();
$old_sessid = session_id();
session_regenerate_id();
$new_sessid = session_id();
session_id($old_sessid);
session_destroy();
session_regenerate_id(FALSE);
session_start();
echo session_id();
echo "<br>";
$sessionid = session_id();
$currentDate = date('Y-m-d');
echo "sessionNUM          = $sessionid\n";
echo "<br>";
echo "<br>";
echo '<pre>' .print_r($_SESSION, TRUE) . '</pre>';
//Connect to DB
require_once 'configPOS.php';
$conn = new mysqli($hn, $un, $pw, $db);
if ($conn->connect_error) die($conn->connect_error);
//Enter Session ID and set Order ID
//search for session info already exsiting
$result=$conn->query("SELECT * FROM POS_HEADERS WHERE sessionid='$sessionid' AND date='$currentDate'");
echo mysql_error();
if(mysqli_num_rows($result) > 0){
echo "session info already exists";
}
else{
echo "test.";
/*
$sessionid = session_id();
*/
$sql="INSERT INTO POS_HEADERS (sessionid, date)
VALUES('$sessionid', '$currentDate')";
if ($conn->query($sql) === TRUE) {
echo "New order started.<br>";
}
else {
echo "Error " . $sql . "<br>" . $conn->error;
}
}
$res=$conn->query("select ORDID from POS_HEADERS where sessionid='$sessionid'");
list($ORDERNUM)= $res->fetch_row();
//echo "<br>";
echo "<br>";
echo "ORDERNUM          = $ORDERNUM\n";
$_SESSION["OrderNum"] = $ORDERNUM;
echo "<br>";
//echo "<br>";
echo "Session variables are set.";
$res=$conn->query("select ORDID from POS_HEADERS where sessionid='$sessionid'");
list($ORDERNUM)= $res->fetch_row();
echo "ORDERNUM= $ORDERNUM\n";
//echo "<br>";
echo $_SESSION["OrderNum"];
$ordernum= $ORDERNUM;
echo $ordernum;
echo '<br>';
$LOCATION = $_POST["pickedlocation"];
echo $LOCATION;
echo "<br>";
echo "<br>";
echo "END Debugging Info";
echo "<br>";
echo "<br>";
echo '<pre>' .print_r($_SESSION, TRUE) . '</pre>';
echo "<br>";
echo session_id();
echo "<br>";
?>
<input type="button" value="Home" class="homebutton" id="btnHome"
onClick="window.location = 'https://www.example.com/POS/home.php'" />
My original problem was
PAGE 2 having one session_id(), lets call it "A",
PAGE 3 had a previous session(id), lets call it "B",
PAGE 4 had session_id() "A" again, and
PAGE 5 had session_id() "B" again.
All pages 2-5 do are insert data into a database for that session_id(), but for some reason PAGE 2 kept creating a new session_id() after PAGE 1 created one, which has got me to where I am now.
Things I have discovered - The session_save_path() is writeable, the url path is identical up to the page (...). Also, on the same URL there are very similar pages in a different directory that work flawlessly, so I think it's a code error, not a php.ini error.