My source code is very big, but I'll try to summarize.
page1.php
I have previous files where I saved some values on session.
<?php
session_start();
include('constants.php');
if (!isset($_SESSION['user'])) {
header("Location: ".RELATIVE_PATH."/field_test/login.php");
exit;
} else {
//Calculate the time passed
$previous_date = $_SESSION["last_access"];
$actual_date = date("Y-n-j H:i:s");
$time_pass = (strtotime($actual_date)-strtotime($previous_date));
//Compare the time passes
if($time_pass >= 28800) {
//If 20 minutes or more
session_destroy(); // destroy session
//Send to the login user page
header("Location: ".RELATIVE_PATH."/field_test/index.php");
//if not, update the date of the session
}else {
$_SESSION["last_access"] = $actual_date;
}
}
$profile = $_SESSION['profile'];
?>
........
......
//Start the html code and the form
<form action="page2.php" method="POST" name="report_gestion" >
<table border="0" width="100%">
<tr>
<td > X :</td>
<td > <select name='x_axis'>
<option label=" " value=""> </option>
<option label="Pair of Sockets" value="pair_sockets">Pair of Sockets</option>
<option label="Max Phy Rate(Mbps)" value="phy_max">Max Phy Rate(Mbps)</option>
<option label="Min Phy Rate(Mbps)" value="phy_min">Min Phy Rate(Mbps)</option>
<option label="Avg Phy Rate(Mbps)" value="phy_avg">Avg Phy Rate(Mbps)</option>
<option label="Avg Throughput(Mbps)" value="xput_avg">Avg Throughput(Mbps)</option>
<option label="Max Throughput(Mbps)" value="xput_max">Max Throughput(Mbps)</option>
<option label="Min Throughput(Mbps)" value="xput_min">Min Throughput(Mbps)</option>
</select>
</td>
<td ><input type="checkbox" name="parameters[]" value="hpav" title="HPAV" />HPAV</td>
<td ><input type="checkbox" name="parameters[]" value="mx" title="MX" disabled/>MX</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td > Y :</td>
<td > <select name='y_axis[]' multiple size= 5 >
<option label="Max Phy Rate(Mbps)" value="phy_max">Max Phy Rate(Mbps)</option>
<option label="Min Phy Rate(Mbps)" value="phy_min">Min Phy Rate(Mbps)</option>
<option label="Avg Phy Rate(Mbps)" value="phy_avg">Avg Phy Rate(Mbps)</option>
<option label="Avg TCP Throughput(Mbps)" value="xput_max">Avg TCP Throughput(Mbps)</option>
<option label="Max TCP Throughput(Mbps)" value="xput_max2">Max TCP Throughput(Mbps)</option>
<option label="Min TCP Throughput(Mbps)" value="xput_min">Min TCP Throughput(Mbps)</option>
<option label="Counters" value="sel_primitives">Counters</option>
</select>
</tr>
</td>
</table>
</form>
If I do print_r($_SESSION); in this file I obtain:
Array ( [profile] => 1 [last_access] => 2010-3-26 12:34:16 [user] => 1 );
what is correct.
Then I send this form to the page2.php
<?php
//Initialize the session for saving the user
session_start();
require_once '../Smarty/libs/Smarty.class.php';
include('../constants.php');
if (!isset($_SESSION['user'])) {
header("Location: ".RELATIVE_PATH."/field_test/login.php");
exit;
} else {
//Calculate the time passed
$previous_date = $_SESSION["last_access"];
$actual_date = date("Y-n-j H:i:s");
$time_pass = (strtotime($actual_date)-strtotime($previous_date));
//Compare the time passes
if($time_pass >= 28800) {
//If 20 minutes or more
session_destroy(); // destroy session
//Send to the login user page
header("Location: ".RELATIVE_PATH."/field_test/index.php");
exit;
//if not, update the date of the session
}else {
$_SESSION["last_access"] = $actual_date;
}
}
$profile = $_SESSION['profile'];
//Read the parameters from the form
$_SESSION['x_axis_session'] = $_POST['x_axis'];
$x_axis_param = $_SESSION['x_axis_session'];
$_SESSION['y_axis_session'] = $_POST['y_axis'];
$y_axis_param = $_SESSION['y_axis_session'];
$_SESSION['parameters_session'] = $_POST['parameters'];
$params = $_SESSION['parameters_session'];
.... I made different calculation correctly
If I do print_r($_SESSION); in this file I obtain:
Array ( [profile] => 1 [last_access] => 2010-3-26 12:39:40 [user] => 1 [x_axis_session] => pair_sockets [y_axis_session] => Array (
* => phy_max ) [parameters_session] => Array (
* => hpav ) )
what is correct.
But when I come back to page1.php and I print the session I obtain:
Array ( [[profile] => 1 [last_access] => 2010-3-26 12:41:31 [user] => 1[x_axis_session] => [y_axis_session] => [parameters_session] => )
Here is where I have the problem, the variables of the form haven't been saved in the session, I don't know why.
I hope the code helps. Let me know if you need more details