InterfaceICookieSetterOptions

写入 cookie 的选项。

interface ICookieSetterOptions {
    domain?: string;
    encode?: ((content: string | number | boolean) => string);
    expires?: string | Date;
    path?: string;
    sameSite?: "none" | "lax" | "strict";
    secure?: boolean;
}

Properties

domain?: string

所在域。

encode?: ((content: string | number | boolean) => string)

Cookie 名和值的编码方式,默认为 encodeURIComponent。

expires?: string | Date

过期时间:

  • 为日期类型时表示绝对时间;
  • 为字符串时表示相对时间,详见 @just4/util 中 addRelativeTime 的说明。
path?: string

所在路径。

sameSite?: "none" | "lax" | "strict"

访问限制:lax、strict 或 none。

secure?: boolean

是否只在 https 连接中有效。