1

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

Ghost
  • 13
  • 6

1 Answers1

1

Because the location header is malformed, so the browser won't follow it. Try:

header("Location: ../index.php");
David
  • 208,112
  • 36
  • 198
  • 279
  • 1
    @Ghost: Have you turned on error reporting? Checked the PHP error logs? Added output to confirm the code is executed at all? – David Jun 12 '19 at 01:04