session variable losing value
Posted: Thu Sep 03, 2009 1:56 pm
Hi,
I have a problem with session variable getting reset.
I have <?php session_start(); ?> on all the pages
File 1 index.php has 2 session variables
$_SESSION['dbhit'] = 0;
$_SESSION['dbresult'] = 0;
File 2 catalog.php has the following code
if($_SESSION['dbhit']==0){
$queryCatalog = 'SELECT catalog.page_id,catalog.name,products.duration,products.dates,products.who,products.prerequisite,products.university FROM `products`,`catalog` WHERE products.page_id = catalog.page_id and catalog.type = "'.$type.'"ORDER BY Rand()';
$resultCatalog = mysql_query($queryCatalog) or die('Query failed: ' . mysql_error());
$_SESSION['dbresult'] = $resultCatalog;
$_SESSION['dbhit'] = 1;
}
$result = $_SESSION['dbresult'];
echo $_SESSION['dbresult'];
now the control moves to File 3 product.php which has a back button, on click of the back button control comes back to file 2 catalog.php, now the session variable $_SESSION['dbresult']; is losing its value.
I have a problem with session variable getting reset.
I have <?php session_start(); ?> on all the pages
File 1 index.php has 2 session variables
$_SESSION['dbhit'] = 0;
$_SESSION['dbresult'] = 0;
File 2 catalog.php has the following code
if($_SESSION['dbhit']==0){
$queryCatalog = 'SELECT catalog.page_id,catalog.name,products.duration,products.dates,products.who,products.prerequisite,products.university FROM `products`,`catalog` WHERE products.page_id = catalog.page_id and catalog.type = "'.$type.'"ORDER BY Rand()';
$resultCatalog = mysql_query($queryCatalog) or die('Query failed: ' . mysql_error());
$_SESSION['dbresult'] = $resultCatalog;
$_SESSION['dbhit'] = 1;
}
$result = $_SESSION['dbresult'];
echo $_SESSION['dbresult'];
now the control moves to File 3 product.php which has a back button, on click of the back button control comes back to file 2 catalog.php, now the session variable $_SESSION['dbresult']; is losing its value.