Please see the test page here https://wintoweb.com/sandbox/question_3.php I use $_SESSION to store results of DB searches but only the last value is stored in the session. Looks like the latter is emptied upon each search.
I've used session before on that server and had no problems. My code is probably faulty but I cannot figure it out. session_start is called at top of file.
<?php
if(isset($_GET['search'])){
} else if(isset($_GET['display_this'])){
$rets = getNames(); //The $rets will hold the value returned by your function getName().
if(!empty($rets)){
echo '</br><b>Your selections so far :</b></br></br>';
}
//But yet, only the last search is stored in the session (why?)
echo "Echo of session array : " . $_SESSION['author'] . "<br>";
}
function getNames(){
$rets = '';
if(isset($_GET['choices']) and !empty($_GET['choices'])){
foreach($_GET['choices'] as $selected){
$rets .= $selected . ' -- ';
// This should add every $rets to the session array. Right?
$_SESSION['author'] = $rets;
//session_write_close();
}
}
return $rets;
}
?>
I expect the session to retain all info from subsequent searches but only the last value is stored.