I'm trying to override all logout situations (timeout-sessions, or simply any method that refers to [logout.php] page!) by specifying a single logout button in the index page. Is this possible? And what did I miss? Thanks in advance.
The code used in the [index.php]:
<?php
session_start();
if(isset($_POST['logout'])) {
$_SESSION['logout_command'] = 1;
header("Location: logout.php");
}
?>
<form action="" method="post">
<input type="submit" name="logout" value="LOGOUT!!!">
</form>
And the code in the [logout.php]:
<?php
session_start();
if(isset($_SESSION['logout_command'])) {
$check = $_SESSION['logout_command'];
if($check = 1) { // AND ONLY IF!
session_destroy();
header("Location: login.php");
} else { // BACK OFF!
header("Location: index.php");
}
} else { // ALSO BACK OFF!
$_SESSION['logout_command'] = 0;
header("Location: index.php");
}
?>
UPDATE: So, I missed the comparing (==) signs... Also, the [exit()] function after each [header()] in a sequence... Thanks to everyone.