note 50557 added to function.setcookie

From: Date: Thu, 03 Mar 2005 10:24:54 +0000
Subject: note 50557 added to function.setcookie
Groups: php.notes 
Request: Send a blank email to php-notes+get-85861@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.setcookie.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50557 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50557&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50557&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50557&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50557&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50557&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50557&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85861) next »