I'm having a problem passing a variable from one PHP file to another PHP file. I'm trying to send the varialbe $insert to another PHP file that will just display it. For the life of me, I can't figure out why it won't work.
Any help would be great! Thanks.
1st PHP File (Sending $insert to $_SESSION['finalimage'])
<?php
session_start();
$insert = rand(5, 1500);
$_SESSION['finalimage'] = $insert;
header("Location: http://www.shmoggo.com/snapshot/snapshot_view.php");
echo base64_decode($_POST["image"]);
$final = base64_decode($_POST["image"]);
$newpath = "uploads/" . $insert . ".jpg";
file_put_contents($newpath, $final);
?>
2nd PHP File (Receiving $insert from $_SESSION['finalimage'])
<?php
session_start();
$insert = $_SESSION['finalimage'];
echo "Image Number = ". $insert;
?>
First thing to check is how your PHP installation is supporting sessions. There are two possible methods for "persisting" the session ID between requests:
1) using cookies or 2) using "URL rewriting" (ie each URL passes a sessionid value)
If you are using cookies check to see if your server is in fact sending a cookie to your browser.
If you are using url-rewriting the Location header that you are sending that re-routes the client browser to "snapshot_view.php" will need to be modified to include the session id. Like this:
$reroute = 'Location: http://www.shmoggo.com/snapshot/snapshot_view.php?PHPSESSID=' . session_id();
header($reroute);