Ok, i’ve written a series of php pages which store user data entered from previous pages. The last page calls an ajax php file, but this ajax file finds almost all of the session vars set previously to be null. All of the other php pages, however, are able to access these vars. Any idea what i’m doing wrong?
index2.php => takes file uploaded from previous page and puts name in session
<?php
session_start();
session_unset();
session_destroy();
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
<?php
session_start();
$_SESSION['file'] = $_FILES['file']['name'];
mkdir("/blend/". $_FILES['file']['name']);
mkdir("/blend/" . $_FILES['file']['name'] . "/frames");
move_uploaded_file($_FILES["file"]["tmp_name"], "/blend/". $_SESSION['file'] . "/scene.blend");
?>
control.php => takes other user input from input2.php and puts into session
<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>
<?php
session_start();
$_SESSION['endFrame'] = $_POST['frameEnd'];
$_SESSION['format'] = $_POST['format'];
$_SESSION['currFrame'] = $_POST['frameStart'];
var_dump($_SESSION);
?>
updateAjax => is the ajax script called by control.php, only $_SESSION[‘file’] appears to be set (this is only a snippet)
function sendInfo() {
$output = array();
$output['status'] = "Currently Rendering";
if (!renderRunning()) {
$output['status'] = "Starting Render";
}
if ( !renderRunning() && renderFinished()) {
$output['status'] = "Zipping all files";
}
$output['currFrame'] = $_SESSION['currFrame'];
$output['lastFrame'] = $_SESSION['endFrame'];
if (renderFinished()) {
$output['downloadButton'] = true;
$output['downloadLink'] = "/var/www/" . $_SESSION['fileDir'] . "/frames.zip";
}
else {
$output['downloadButton'] = false;
}
$output['imgSrc'] = $_SESSION['imgSrc'];
$output['status'] = var_dump($_SESSION);
echo json_encode($output);
}