<?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['IdUser'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['IdUser']);
  unset($_SESSION['PrevUrl']);

  //$logoutGoTo = "http://localhost/msngrapa/";
 $logoutGoTo = $Url."";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
