Teal TealUI

Cookie 处理扩展web/cookie/cookie-more

提供更多 Cookie 处理功能。

API

函数 描述
⮞ getAllCookies()():object

获取所有 Cookie。

返回值

类型:{ [key: string]: string; }

返回包含所有 Cookie 的键值对。

示例

getAllCookies()

获取所有 Cookie。

⮞ getSubcookie(name, subname)(name:string, subname:string):string

获取指定的子 Cookie 值。

参数 类型 描述 默认值
name* string —
subname* string —

返回值

类型:string

返回对应的 Cookie 值。如果 Cookie 不存在则返回 null。

示例

getSubcookie("sample", "child") // 如果不存在则返回 null。

获取指定的子 Cookie 值。

⮞ setSubcookie(name, subname, value, ...)(name:string, subname:string, value:string, expires?:number, path?:string, domain?:string, secure?:string):void

设置或删除指定的子 Cookie 值。

参数 类型 描述 默认值
name* string —
subname* string —
value* string —
expires number —
path string —
domain string —
secure string —

返回值

类型:void

示例

setSubcookie("sample", "child", "the value") // 设置子 Cookie
setSubcookie("sample", "child", undefined) // 删除子 Cookie

设置或删除指定的子 Cookie 值。