ho provato così però non mi funziona:

<?
if (isset($_GET['action']) && $_GET['action']=='logout') {
logout();
}
function logout() {
unset($_SESSION['logout']);
session_destroy();
header("Location: index.php");
}
?>
dove sbaglio?