PHP会话_write_close()导致响应为空

PHP会话_write_close()导致响应为空,php,session,Php,Session,在脚本末尾的关闭函数中使用session_write_close()时,PHP就死了。没有错误记录、响应标题(firebug)或数据(甚至空白!)返回。在启用了STRICT和PHP5.2.1的情况下,我有完整的PHP错误报告 我的猜测是,由于session_write_close()在关闭后被调用,因此遇到了一些致命错误,导致PHP在有机会发送输出或记录任何内容之前崩溃 这仅发生在注销页面上,我首先: ... //If there is no session to delete (not

在脚本末尾的关闭函数中使用session_write_close()时,PHP就死了。没有错误记录、响应标题(firebug)或数据(甚至空白!)返回。在启用了STRICT和PHP5.2.1的情况下,我有完整的PHP错误报告

我的猜测是,由于session_write_close()在关闭后被调用,因此遇到了一些致命错误,导致PHP在有机会发送输出或记录任何内容之前崩溃

这仅发生在注销页面上,我首先:

...
    //If there is no session to delete (not started)
    if ( ! session_id())
    {
        return;
    }

    // Get the session name
    $name = session_name();

    // Delete the session cookie (if exists)
    if ( ! empty($_COOKIE[$name]))
    {
        //Get the current cookie config
        $params = session_get_cookie_params();

        // Delete the cookie from globals
        unset($_COOKIE[$name], $_SESSION);

        //Delete the cookie on the user_agent
        setcookie($name, '', time()-43200, $params['path'], $params['domain'], $params['secure']);
    }

    // Destroy the session
    session_destroy();
...
然后2)做更多的事情3)发出重定向,4)最后,在完成整个页面后,
register_shutdown_function()我放置了先前的运行并调用session_write_close(),它将会话保存到数据库中。结束


由于此空白响应仅在注销时出现,我猜我没有正确重新启动会话,这导致会话_write _close()在脚本结束时死亡。

。问题似乎在于,我正在删除cookie之前销毁会话

这项工作:

    // Delete the session cookie (if exists)
    if ( ! empty($_COOKIE[$name]))
    {
        //Get the current cookie config
        $params = session_get_cookie_params();

        // Delete the cookie from globals
        unset($_COOKIE[$name], $_SESSION);

        //Delete the cookie on the user_agent
        setcookie($name, '', time()-43200, $params['path'], $params['domain'], $params['secure']);
    }

    // Destroy the session -----------------------------------------
    session_destroy();
这会终止页面:

    // Destroy the session -----------------------------------------
    session_destroy();

    // Delete the session cookie (if exists)
    if ( ! empty($_COOKIE[$name]))
    {
        //Get the current cookie config
        $params = session_get_cookie_params();

        // Delete the cookie from globals
        unset($_COOKIE[$name], $_SESSION);

        //Delete the cookie on the user_agent
        setcookie($name, '', time()-43200, $params['path'], $params['domain'], $params['secure']);
    }

有人知道为什么吗?

为什么需要session\u write\u close()呢?为了确保session保存在某些版本的PHP中,我想。session在脚本末尾自动写入和关闭。PHP 5.0.5有一个需要这样做的bug,它不应该影响其他版本。5.0.5是4年前发布的。在5.1.4之前,PHP5.1.x是很奇怪的。现在您正试图解决不存在的问题。正当