NYCPHP Meetup

NYPHP.org

[nycphp-talk] deleting cookies

Michael Southwell michael.southwell at nyphp.com
Mon Jan 28 21:44:36 EST 2008


I'm having trouble getting some cookies deleted.

I'm storing login data in the session, and setting a two-week loginID 
cookie to bypass the need to login again upon later visits. The logout 
script uses the following code to destroy the session (which works) and 
to attempt to delete the session and loginID cookies. But that is not 
working, and those cookies are still alive if the user navigates away 
from the logout page to another page, so she is automatically logged 
right back in just as if she were coming back a week later.
================
session_start();
$_SESSION = array();
setcookie( session_id(), '', time() - 3600 );
session_destroy();
setcookie( 'loginID', '', time() - 3600 );
================
What am I doing wrong?
-- 
=================
Michael Southwell
Vice President, Education
NYPHP TRAINING:  http://nyphp.com/Training/Indepth



More information about the talk mailing list