Session Problems !!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sacfreak
Forum Newbie
Posts: 6
Joined: Tue Mar 11, 2003 3:10 am

Session Problems !!

Post 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;
}
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply