session_destroy() and setcookie fail
<p>I'm trying to logout of my page but session_destroy and setting cookies does not work. Here's my code:</p>

<pre><code>    $page = $_GET["page"];
    if ($page == "logout") {
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();


echo &lt;&lt;&lt;html
        &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="center"&gt;&lt;b&gt;&lt;font color="#000080"&gt;You've successfully logged out.&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
        &lt;p align="right"&gt;&lt;b&gt;&lt;font size="3" color="#FF0000"&gt;Redirecting...&lt;/font&gt;&lt;/b&gt;&lt;/td&gt;
html;
echo ("&lt;META HTTP-EQUIV=Refresh CONTENT=\"4; URL=index.php\"&gt;");
exit ();
</code></pre>

<p>But its not working - the session is not destroyed and cookies remain the same. I've also tried just setting a cookie to a different value with no success. Other parts of the code create cookies, access and use them, but in the logout part I cant destroy them. Can someone tell me what's wrong here? Should cookies and sessions be set/unset/destroyed at the beginning of the page like session_start? Or is something else wrong?</p>
