0

I have a website which has a session system. In the main page i have a logout button which calls a logout.php file. The file contains:

    <?PHP
        unset($_SESSION['user_id']);
        unset($_SESSION['user_name']);
        unset($_SESSION['user_admin']);
        unset($_SESSION['user_coins']);
        unset($_SESSION['user_email']);
        unset($_SESSION['user_createtime']);

        header("Location: index.php");
    ?>

The file runs like it should, it ends the session but it doesn't do the redirect. It just ends the session and stops there. What can be the problem?

  • 1
    most likely outputting before header. – Funk Forty Niner Oct 16 '17 at 18:56
  • Turn on error reporting - always when developing and testing code, at the top of your script `error_reporting(E_ALL); ini_set('display_errors', 1);` Almost certainly you are facing some variant of [How to fix Headers already sent](https://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php) – Michael Berkowski Oct 16 '17 at 18:58
  • If for example your real code has whitespace before the opening ` – Michael Berkowski Oct 16 '17 at 18:59

0 Answers0