Code:
/**
 * process all $_SESSION terms
 */
  if (isset($_SESSION) && count($_SESSION) > 0) {
    foreach($_SESSION as $key=>$value){
      if(is_array($value)){
        foreach($value as $key2 => $val2){
          unset($GLOBALS[$key]);  // <<-- shouldn't this be key2 ?
        }
      } else {
        unset($GLOBALS[$key]);
      }
    }
  }