0 && $options['expires'] < 36500) { $options['expires'] = time() + ($options['expires'] * 86400); } else { // Session cookie or Unix timestamp, no change } // Set defaults. if (!array_key_exists('path', $options)) { $options['path'] = config('cookie.path') ?? '/'; } if (!array_key_exists('domain', $options) && ($default_domain = config('cookie.domain'))) { $options['domain'] = $default_domain; } if (!isset($options['secure'])) { $options['secure'] = \RX_SSL && !!config('session.use_ssl_cookies'); } if (!isset($options['httponly'])) { $options['httponly'] = config('cookie.httponly') ?? false; } if (!isset($options['samesite'])) { $options['samesite'] = config('cookie.samesite') ?? 'Lax'; } $result = setcookie($name, $value, $options); // Make the cookie immediately available server-side. if ($result && $options['expires'] >= 0) { $_COOKIE[$name] = $value; } return $result; } /** * Delete a cookie. * * You must pass an options array with the same values that were used to * create the cookie, except 'expires' which doesn't apply here. * * @param string $name * @param array $options * @return bool */ public static function remove(string $name, array $options = []): bool { // Setting the expiry date to a negative number will take care of it. $options['expires'] = -1; $result = self::set($name, '', $options); // Make the cookie immediately unavailable server-side. if ($result) { unset($_COOKIE[$name]); } return $result; } }