Session cookie not being deleted on logout

Hi I am seeing how my cookies are created and destroyed using the firefox cookie editor add-on.

I am using the following code to delete the session cookie on logout:

    // Delete the session cookie by setting its expiration to an hour ago (3600)
    if ( isset($_COOKIE[session_name()]) ) {        
        setcookie(session_name(), '', time() - 3600);

What is baffling me is that when I am logged out and am back to the login page, the cookie editor still shows a cookie with name PHPSESSID, which should have been deleted with the code above.

Am I doing something wrong?


It does not guarantee the cookie will be deleted at that moment you issues the above code. It merely sets the value of the cookie to blank and sets an expires header in the past to coax the browser to delete it when it handles cleanup.