Cookies.jsCookie JavaScript 库
Cookies.js 是一个客户端的 Cookie 操作的 JavaScript 库。
示例代码:
// Setting a cookie value Cookies.set('key', 'value'); // Chaining sets together Cookies.set('key', 'value').set('hello', 'world'); // Setting cookies with additional options Cookies.set('key', 'value', { domain: 'www.example.com', secure: true }); // Setting cookies with expiration values Cookies.set('key', 'value', { expires: 600 }); // Expires in 10 minutes Cookies.set('key', 'value', { expires: '01/01/2012' }); Cookies.set('key', 'value', { expires: new Date(2012, 0, 1) }); // Using the alias Cookies('key', 'value', { secure: true });
评论