I have a logout button on my site's navigation bar (which appears on every page on the site). It only seems to logout the user when the user is already on the home page. If they are on any other page of the site, the logout button only redirects to the homepage but all the $_SESSION variables are still set.
HTML (from navigation bar)
<form class = "dropdown-item "action="includes/logout.inc.php" method="POST">
<button class="btn btn-success navbar-btn" type="submit" name ="submit" >Logout</button>
</form>
PHP (/logout.inc.php)
if (isset($_POST['submit'])) {
session_start();
session_destroy();
header("Location: ../home.php");
}
I also tried adding $_SESSION = array(); to the php script but this made no difference.