From bcc47f6f3abb6f1c35913f0a4ef871c646d79398 Mon Sep 17 00:00:00 2001 From: Garvin Hicking Date: Mon, 14 Jul 2008 08:02:28 +0000 Subject: [PATCH] fix cookie removal to use proper host --- docs/NEWS | 3 +++ include/functions_config.inc.php | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/NEWS b/docs/NEWS index 1ef6fd5f..0db739e1 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,9 @@ Version 1.4 () ------------------------------------------------------------------------ + * Make cookie deletion routine use the same host like cookie + insertion, thanks to JPhilip + * Added optional token insertion for comment notification (moderation) e-mails, which you can click without the need for authentication. This is a convenience feature, note that diff --git a/include/functions_config.inc.php b/include/functions_config.inc.php index b6a1a57a..0d463ede 100644 --- a/include/functions_config.inc.php +++ b/include/functions_config.inc.php @@ -620,7 +620,7 @@ function serendipity_setCookie($name, $value, $securebyprot = true) { // If HTTP-Hosts like "localhost" are used, current browsers reject cookies. // In this case, we disregard the HTTP host to be able to set that cookie. - if (substr_count($host, '.') < 2) { + if (substr_count($host, '.') < 1) { $host = ''; } @@ -646,6 +646,12 @@ function serendipity_deleteCookie($name) { $host = substr($host, 0, $pos); } + // If HTTP-Hosts like "localhost" are used, current browsers reject cookies. + // In this case, we disregard the HTTP host to be able to set that cookie. + if (substr_count($host, '.') < 1) { + $host = ''; + } + setcookie("serendipity[$name]", '', time()-4000, $serendipity['serendipityHTTPPath'], $host); unset($_COOKIE[$name]); unset($serendipity['COOKIE'][$name]);