Reputation: 13
so im trying to log my user out and return them to the home screen but im just getting redirected to my logout.php file (white screen) any help here is the code:
(logout.php file)
<?php
session_Start();
unset($_SESSION['user_id']);
header("location../index.php");
?>
Button:
<li class="nav-item">
<?php if(isset($_SESSION['user_id'])): ?>
<a href="logout.php" class="nav-link btn-success logout-btn">Logout</a>
<?php endif; ?>
</li>
tried a bunch of different things and nothings working i expect to be redirected to the index.php login screen
Upvotes: 1
Views: 154
Reputation: 218867
Because the location header is malformed, so the browser won't follow it. Try:
header("Location: ../index.php");
Upvotes: 1