@0x44ru5h/cookie-jar 中文文档教程
Cookie Jar v0.0.1
a small api for cookies
Overview
cookie-jar
是一个最小的 javascript 库,它允许开发人员快速、简单、高效地访问和使用 cookie。
API
set(name, value)
创建一个 cookie
jar.set("username", "aarushgupta")
上面的代码创建了一个名为 username
和值为 aarushgupta
的 cookie。
get(name)
获取cookie的值
jar.get("username")
上面的代码返回aarushgupta
,即username
的值集。
update(name, new)
更新 cookie
jar.set("username", "theaarushgupta")
的值代码更新 username
并将其值更改为 theaarushgupta
。
remove(name)
删除 cookie
jar.remove("username")
上面的代码删除了 cookie username
。
Examples
Basic Usage
let jar = new Jar()
jar.set("username", "aarushgupta")
console.log(jar.get("username"))
jar.update("username", "theaarushgupta")
console.log(jar.get("username"))
jar.remove("username")
这段代码设置一个 cookie,获取它的值,更新它,然后删除它,展示了类似 REST 的 Jar
类的简单性。
控制台输出
aarushgupta
theaarushgupta
Browser Compatibility
cookie-jar
适用于所有现代浏览器,包括桌面和移动设备。
Copyright © 2021 Aarush Gupta
此代码受版权保护,但根据 GNU AGPLv3 许可证和任何更高版本授权给公众。
Cookie Jar v0.0.1
a small api for cookies
Overview
cookie-jar
is a minimal javascript library that allows developers to access and use cookies quickly, simply, and efficiently.
API
set(name, value)
Create a cookie
jar.set("username", "aarushgupta")
The code above creates a cookie with name username
and value aarushgupta
.
get(name)
Get the value of a cookie
jar.get("username")
The code above returns aarushgupta
, the value set of username
.
update(name, new)
Update the value of a cookie
jar.set("username", "theaarushgupta")
The code updates username
and changes its value to theaarushgupta
.
remove(name)
Removes a cookie
jar.remove("username")
The code above removes the cookie username
.
Examples
Basic Usage
let jar = new Jar()
jar.set("username", "aarushgupta")
console.log(jar.get("username"))
jar.update("username", "theaarushgupta")
console.log(jar.get("username"))
jar.remove("username")
This code sets a cookie, gets its value, updates it, and then removes it, showing the simplicity of the REST-like Jar
class.
Console output
aarushgupta
theaarushgupta
Browser Compatibility
cookie-jar
works in all modern browsers, both desktop and mobile.
Copyright © 2021 Aarush Gupta
This code is copyrighted but licensed to the public under the GNU AGPLv3 license and any later versions.