I've been doing a deep research in the web, looking for a solution for this error, but I couldn't fix it yet. Let me introduce you the situation:
SCRIPT1.php:
if(isset($_SESSION['LoadFile'])){
echo "<span>";
$MsgId = 91;
$Msg = GetMsg($language, $MsgId);
echo $Msg . " ";
echo "<input name=\"Fleet\" id=\"Fleet\" type=\"file\" />";
echo "</span>";
}else{
echo "<span>";
$MsgId = 169;
$Msg = GetMsg($language, $MsgId);
echo $Msg . " ";
$MsgId = 22;
$Msg = GetMsg($language, $MsgId);
echo "<a href=\"".$linkpath."inc_load_file.php\">".$Msg."</a>";
echo "</span>";
}
The inc_load_file.php contents:
<?php
$_SESSION["LoadFile"] = "Load, please";
$_SESSION["ShowLoadingOpt"] = "Show";
//echo $_SESSION["LoadFile"] <---This works correctly, the variable is being properly created.
header("Location: ".$_SESSION["PrevLoc"]);
exit;
?>
Note that if I do print_r($_SESSION) in the begging of the Script1, it shows the following result:
Array (
[UID] => 1
[UName] => Santi
[USurname] => Márquez
[ULvl] => 1
[ULang] => en_Gb
[Logged] => 1
[UEmail] => [email protected]
[User] => smarquez
[UCreationDate] => 2015-10-14
[UAccessTimes] => 162
[UALDesc] => Administrator
[CountryCodeKPIReportsGenerator] => 2
)
My webpage should show a message like:
"File loaded. If you want to load a new file click here."
If you click in the link, the inc_load_file.php is executed. It creates the session variables and goes back to the script1.php. After doing it, the webpage should show a file input, but actually, it's still showing the link. The session variable is not set.
Can you please help me to check why the session variables created in inc_load_file.php are not being properly returned after executing the header() function?
Thank you very much in advance for your help.
session_start(). no session_start, any changes to $_SESSION are simply lost.