note 50557 deleted from function.setcookie by didou
| From: | didou@php.net | Date: | Thu, 03 Mar 2005 17:05:34 +0000 |
| Subject: | note 50557 deleted from function.setcookie by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-85870@lists.php.net to get a copy of this message | ||
Note Submitter: s.j.eggen (at) phys.uu.nl
Reason: bad code
----
probably pretty useful trick I just figured out...
how to _delete_ a cookie in PHP4:
set_cookie($name, '', $exp, $path, $dom, $sec);
// if you are deleting a session-id-cookie, use session_name() for $name
// and session_get_cookie_params() to get $exp, $path, etc.
how to _ignore_ a cookie in PHP4:
unset($_COOKIE[$name]);
This is useful because sometimes you just want to ignore a cookie, not delete it. In this case you
just use the second snippet -- the cookie will not be deleted.
Sometimes you want to delete a cookie _and_ ignore it from that moment on in your code -- not the
next time the code runs. In that case you use both snippets.