CookieOptions

接口

{@link setCookie}/{@link removeCookie} 支持的 Cookie 属性

签名

interface CookieOptions {
    expires?: number | Date | undefined
    maxAge?: number | undefined
    path?: string | undefined
    domain?: string | undefined
    secure?: boolean | undefined
    sameSite?: "strict" | "lax" | "none" | undefined
}

成员

名称类型描述
expires可选number | Date | undefined过期时间:数字表示从现在起的天数,也可以直接传 Date
maxAge可选number | undefined过期秒数,与 expires 同时提供时两者都会写入(由浏览器自行取用)
path可选string | undefinedCookie 生效路径,默认 `/`
domain可选string | undefinedCookie 生效域名,默认不设置(即当前域名)
secure可选boolean | undefined是否只在 HTTPS 下发送
sameSite可选"strict" | "lax" | "none" | undefined跨站请求携带策略;取值 'none' 时按规范需要同时设置 secure: true,本包不做强制校验

源码

packages/storage/src/types.ts:30