php setcookie时value为null或空字符串,会删除此cookie
长久以来,在php中删除cookie的时候,都是使用
bool setcookie ( string $name [, string $value [, int $expire = 0
[, string $path [, string $domain [, bool $secure = false [, bool
$httponly = false ]]]]]] )
$value 随便写, $expire设置为一个已经过去的时间即可。
官方文档中也是这样写的:
http://www.php.net/manual/en/function.setcookie.php
Example #2 setcookie() delete example When deleting a cookie you should assure that the expiration date is in the past, to trigger the removal mechanism in your browser. Examples follow how to delete cookies sent in previous example: <?php // set the expiration date to one hour ago setcookie ("TestCookie", "", time() - 3600); setcookie ("TestCookie", "", time() - 3600, "/~rasmus/", "example.com", 1); ?> |
…
[获取更多]