alorel/alo-cookie

此包已被废弃且不再维护。未建议替代包。

简单的JavaScript Cookie管理器

安装: 181

依赖项: 0

建议者: 0

安全性: 0

星标: 0

关注者: 2

分叉: 0

开放问题: 0

语言:HTML

类型:项目

1.1 2015-11-19 16:26 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:49:23 UTC


README

Logo

License

这是什么魔法?

这是一个用于以面向对象的方式操作cookie的简单类。

用法

获取所有文档cookie

var cookies = AloCookie.getAll();
// {name1:value1, name2:value2 ...}

设置cookie "foo"

var cookie = new AloCookie("foo");
cookie.value = "bar";
cookie.expire = 3600; //in 1 hour. Defaults to expire at the end of the session
cookie.domain = "www.example.com"; //defaults to window.location.hostname
cookie.path = "/cart/checkout"; // Defaults to "/"
cookie.secure = true; // true sends the cookie only via HTTPS. Defaults to window.location.protocol == "https:"
cookie.save()

检查名为 "foo" 的cookie是否存在

var cookie = new AloCookie("foo"),
cookieExists = cookie.exists();

删除cookie "foo"

var cookie = new AloCookie("foo");
cookie.remove();