不朽的PHP会议

I'm having some issues in destroying a session for a logout. When I destroy the session it keeps coming back.

The code I am using is as follows:

public function kill_login(){
    global $response;
    session_start();
    $response->message = "Current session" . json_encode($_SESSION);
    // Unset all of the session variables.
    unset($_SESSION);
    $_SESSION = array();
    if (ini_get("session.use_cookies")) {
        $params = session_get_cookie_params();
        setcookie(session_name(), '', time() - 42000,
            $params["path"], $params["domain"],
            $params["secure"], $params["httponly"]
        );
    }
    session_destroy();
    session_write_close();

    $response->message .= "Session Destroyed" . json_encode($_SESSION);
}

It replies with below

Returning Session

This is called with ASync AJAX Request then reloads

$("<button>").text("Logout").click(function(){
    var logOut = {
        action:"logOut"
    };
    alert(SAJAX.getJSON(logOut,dataLoc).message);
    location.reload();
})

(SAJAX.getJSON is just a method that simplifies using AJAX for a standard request for mine, I use it a lot just fine)

The page then reloads and somehow the session is still there, I can click the logout button again and still get the same thing.

I only have session_start() used in three places: checking login (establishes session for the page), logon and killing a login since it is an AJAX request.

Any Ideas??

Edit: I adjusted it to remove the second session_start() and add write_close same results.

The problem is not in the PHP it is with the call to location.reload(); which will resend the POST data. Since the page was immediately POSTed to by the log-in page the session was being destroyed by the log-out call then a new session was being created due to the POST to the page being resent initiating the login method.

Changing the location.reload() to window.location.href = "logon.php";resolves the issue since the page was no longer being sent the POST data.