Sessions not clearing and setting properly
I'm having trouble with sessions clearing and then being set again.
Basically, I have built a forum where there are a number of different categories, and I have created a breadcrumbs effect for each forum category from he top level down to inserts and replies, but for some reason, on the insert page, it won't give the right forum category name that I'm posting in. So, the bread crumbs for a new post would look like:
Forum <-- Rallies shows & events <-- New post
By this, I am adding a new post into Rallies shows & events, however, if I move to another category then Rallies shows & events remains persistent.
At the top of the code I have this to kill the required session USES_forumID:
<?php
@session_start();
if ("" == ""){
// WA_ClearSession
$clearAll = FALSE;
$clearThese = explode(",","USES_forumID,USES_access");
if($clearAll){
foreach ($_SESSION as $key => $value){
unset($_SESSION[$key]);
}
}
else{
foreach($clearThese as $value){
unset($_SESSION[$value]);
}
}
}
?>
Then I create a new recordset to enable me to get the session ID for the correct category:
$colname_rs_forumname = "-1";
if (isset($_GET['catID'])) {
$colname_rs_forumname = $_GET['catID'];
}
mysql_select_db($database_conn_mrs, $conn_mrs);
$query_rs_forumname = sprintf("SELECT * FROM tbl_forumNAME WHERE fld_fnID = %s", GetSQLValueString($colname_rs_forumname, "int"));
$rs_forumname = mysql_query($query_rs_forumname, $conn_mrs) or die(mysql_error());
$row_rs_forumname = mysql_fetch_assoc($rs_forumname);
$totalRows_rs_forumname = mysql_num_rows($rs_forumname);
And then I reset the session USES_forumID:
<?php
if (!session_id()) session_start();
if(!($totalRows_rs_forumname == 0)) {
$_SESSION["USES_forumID"] = "".$row_rs_forumname['fld_fnID'] ."";
}
?>
Is this too much for a page to handle? Have I done something wrong?
Basically, the first forum category I visit is set by the session and remains persistent even when moving from one to another.
I have attached the top level forum page (forum.php), the results (forum_results.php) list for individual categories and the insert page (forum_insert.php) for you to see if you want to.