Page 1 of 1

Session Problems !!

Posted: Mon Apr 21, 2003 1:28 am
by sacfreak
hi,
i have a common php page which initialises a few session variables. this is included in two other PHP pages. in one page i check the value of one particular variable. if it is one i do some processing.. in common i make it one (if it has not already being set). i use the new values of the other variables in the 2nd PHP page... but both scripts seem to break the
if (!isset()) in common and reinitialise variables everytime, thus causing problems in other PHP scripts....i have included important parts of Common.php and the 1st PHP file....Please help..as i cannot do without sessions...

session_start();
if (!isset($_SESSION["sessDetail"],$_SESSION["sessCartVis"],$_SESSION["sessVARS"]))
{
$_SESSION["sessAllItems"]="";
$_SESSION["sessAllCost"]="";
$_SESSION["sessVARS"]="";
//$sessCartIdx=1;
$_SESSION["sessDetail"]=1; //session that needs to be initalised
}

1st PHP page
include "common_classes1.php";
session_start();
setcon();

if ($_SESSION["sessDetail"]==1)
{
echo"SessDetail:- "; echo $_SESSION["sessDetail"]; echo"<br>";
$_SESSION["sessDetail"]=2; //this gets reinitialised to 1 $_SESSION["sessCategory"]=$_POST["sltCategory"];
$_SESSION["sessVARS"]=$HTTP_POST_VARS;
}

Posted: Mon Apr 21, 2003 4:30 am
by twigletmac
Try doing a bit of debugging - to check what's in your $_SESSION array at various points add this code wherever you want to check:

Code: Select all

echo '<pre>';
print_r($_SESSION);
echo '</pre>';
Mac