How do I delete a cookie.
Not only deleting it's context but the whole cookie.

I have a script where it checks ifthere are a cookie, so it has to be deleted completelly when I log out.

    MichaelHe wrote:

    How do I delete a cookie.
    Not only deleting it's context but the whole cookie.

    I have a script where it checks ifthere are a cookie, so it has to be deleted completelly when I log out.

    setcookie('name','value',(time()-24*3600),'/');

    setcookie

      Basically you have to set the cookie with a expiry date in the past. This does the trick.

      As it needs to be in the past, I normally use a constant date:

      	$expiry = gmmktime(0,0,0, // hms
      		1, // month
      		1, // day
      		2005 // year
      		);
      	setcookie(AUTH_COOKIE_NAME, 'Delete', 
      		$expiry,  // expiry
      		'/'); // path
      

      Mark

        One more thing, set the value of the cookie to null that should do the trick too ...

          Thanks a lot you 2... It works like a charm :o)))

            Write a Reply...