From 3a97088971109f1611a03329d12e5296a8c3c515 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sun, 3 May 2015 11:25:06 +0100 Subject: make it possible to remove entries from DOKU_PREFS cookie --- inc/common.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 5a8b5c900..e14bd7af4 100644 --- a/inc/common.php +++ b/inc/common.php @@ -1875,6 +1875,7 @@ function get_doku_pref($pref, $default) { /** * Add a preference to the DokuWiki cookie * (remembering $_COOKIE['DOKU_PREFS'] is urlencoded) + * Remove it by setting $val to false * * @param string $pref preference key * @param string $val preference value @@ -1891,12 +1892,17 @@ function set_doku_pref($pref, $val) { $enc_pref = rawurlencode($pref); for($i = 0; $i < $cnt; $i += 2) { if($parts[$i] == $enc_pref) { - $parts[$i + 1] = rawurlencode($val); + if ($val !== false) { + $parts[$i + 1] = rawurlencode($val); + } else { + unset($parts[$i]); + unset($parts[$i + 1]); + } break; } } $cookieVal = implode('#', $parts); - } else if (!$orig) { + } else if (!$orig && $val !== false) { $cookieVal = ($_COOKIE['DOKU_PREFS'] ? $_COOKIE['DOKU_PREFS'].'#' : '').rawurlencode($pref).'#'.rawurlencode($val); } -- cgit v1.2.3