Session values aren't being saved for later use
Posted: Fri Jul 13, 2012 12:59 pm
Hi! I'm a PHP-newbie and stumbled upon a problem which is about to get me quite frustrated. What I'm attempting to write is a harmonograph capable of remembering the parameters of five previously generated figures. Drawing is done in Flash and the user interface relies on PHP. For some reason the $_SESSION appears to be empty every time I reload the page.
Code: Select all
<?php
session_start();
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="hGraphStyle.css" />
</head>
<div id="wrapper">
<div id="flash">
<?php
$supt = $_GET['supt'];
// ... gets eighteen different values ...
$fps = $_GET['fps'];
// ... echoes, unrelated to the issue ...
for ($i = 0; $i <= 4; $i++) { // Is supposed to generate thumbnail pics of the previuos figures
if (isset($_SESSION[$i])){ // in case there's the information to draw them from
echo "<tn>";
echo "<object type='application/x-shockwave-flash' data='hGraphTn.swf?supt=".$_SESSION[$i]['supt'].
"&dt=".$_SESSION[$i]['dt']."&Ax=".$_SESSION[$i]['Ax']."&fx=".$_SESSION[$i]['fx'].
"&dfx=".$_SESSION[$i]['dfx']."&px=".$_SESSION[$i]['px']."&dpx=".$_SESSION[$i]['dpx'].
"&As=".$_SESSION[$i]['As']."&fs=".$_SESSION[$i]['fs']."&dfs=".$_SESSION[$i]['dfs'].
"&ps=".$_SESSION[$i]['ps']."&dps=".$_SESSION[$i]['dps']."&Ay=".$_SESSION[$i]['Ay'].
"&fy=".$_SESSION[$i]['fy']."&dfy=".$_SESSION[$i]['dfy']."&py=".$_SESSION[$i]['py'].
"&dpy=".$_SESSION[$i]['dpy']."&d=".$_SESSION[$i]['d']."&fps=".$_SESSION[$i]['fps'].
"' width='100' height='100'></object>";
echo "</tn>";
}
}
// ... echoes, unrelated to the issue ...
for ($k = 4; $k > 0; $k--) {
if (isset($_SESSION[$k-1])) $_SESSION[$k] = $_SESSION[$k-1];
}
$_SESSION[0] = $_GET; // saves the current figure
?>
</div>
</div>
</html>