> $keyValues */ public static function _params(array $keyValues): void { if (!self::$volatile && !self::$locked) { session_start(); } foreach ($keyValues as $key => $value) { if ($value === false) { unset($_SESSION[$key]); } else { $_SESSION[$key] = $value; } } if (!self::$volatile && !self::$locked) { session_write_close(); } } /** * Allows to delete a session * @param bool $force if false, does not clear the language parameter */ public static function unset_session(bool $force = false): void { $language = self::param('language'); if (!self::$volatile) { session_destroy(); } $_SESSION = array(); if (!$force) { self::_param('language', $language); Minz_Translate::reset($language); } } public static function getCookieDir(): string { // Get the script_name (e.g. /p/i/index.php) and keep only the path. $cookie_dir = ''; if (!empty($_SERVER['HTTP_X_FORWARDED_PREFIX'])) { $cookie_dir .= rtrim($_SERVER['HTTP_X_FORWARDED_PREFIX'], '/ '); } $cookie_dir .= empty($_SERVER['REQUEST_URI']) ? '/' : $_SERVER['REQUEST_URI']; if (substr($cookie_dir, -1) !== '/') { $cookie_dir = dirname($cookie_dir) . '/'; } return $cookie_dir; } /** * Specifies the lifetime of the cookies * @param int $l the lifetime */ public static function keepCookie(int $l): void { session_set_cookie_params($l, self::getCookieDir(), '', Minz_Request::isHttps(), true); } /** * Regenerate a session id. * Useful to call session_set_cookie_params after session_start() */ public static function regenerateID(): void { session_regenerate_id(true); } public static function deleteLongTermCookie(string $name): void { setcookie($name, '', 1, '', '', Minz_Request::isHttps(), true); } public static function setLongTermCookie(string $name, string $value, int $expire): void { setcookie($name, $value, $expire, '', '', Minz_Request::isHttps(), true); } public static function getLongTermCookie(string $name): string { return $_COOKIE[$name] ?? ''; } }