summaryrefslogtreecommitdiffstats
path: root/inc/util.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/util.inc.php')
-rw-r--r--inc/util.inc.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/inc/util.inc.php b/inc/util.inc.php
index c33bbc83..9c9d4e58 100644
--- a/inc/util.inc.php
+++ b/inc/util.inc.php
@@ -534,4 +534,24 @@ SADFACE;
return implode(' ', $parts) . ' ' . gmdate($showSecs ? 'H:i:s' : 'H:i', $seconds);
}
+ /**
+ * Properly clear a cookie from the user's browser.
+ * This recursively wipes it from the current script's path. There
+ * was a weird problem where firefox would keep sending a cookie with
+ * path /slx-admin/ but trying to delete it from /slx-admin, which php's
+ * setcookie automatically sends by default, did not clear it.
+ * @param string $name cookie name
+ */
+ public static function clearCookie($name)
+ {
+ $parts = explode('/', $_SERVER['SCRIPT_NAME']);
+ $path = '';
+ foreach ($parts as $part) {
+ $path .= $part;
+ setcookie($name, '', 0, $path);
+ $path .= '/';
+ setcookie($name, '', 0, $path);
+ }
+ }
+
}