<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
    $_SESSION['myMM_Username'] = NULL;
    $_SESSION['myMM_Fullname'] = NULL;
    $_SESSION['PrevUrl'] = NULL;
    $_SESSION['myMM_Userid'] = NULL;
    $_SESSION['security'] = NULL;
    $_SESSION['branch_id'] = NULL;
    $_SESSION['main_branch'] = NULL;
    $_SESSION['branch_name'] = NULL;
    $_SESSION['branch_code'] = NULL;
    $_SESSION['change_price'] = NULL;
    $_SESSION['branch_type'] = NULL;
    
    unset($_SESSION['security']);
    unset($_SESSION['myMM_Userid']);
    unset($_SESSION['myMM_Fullname']);
    unset($_SESSION['MM_Username']);
    unset($_SESSION['PrevUrl']);
    unset($_SESSION['branch_id']);
    unset($_SESSION['main_branch']);
    unset($_SESSION['branch_name']);
    unset($_SESSION['branch_code']);
    unset($_SESSION['change_price']);
    unset($_SESSION['branch_type']);

    $logoutGoTo = "index.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>