Là một dự án mã nguồn mở, carhartl/jquery-cookie đã đạt 8.5k sao trên GitHub, ngôn ngữ JavaScript. No longer maintained, superseded by JS Cookie:
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
This project was moved to https://github.com/js-cookie/js-cookie, check the discussion.
New issues should be opened at https://github.com/js-cookie/js-cookie/issues
jquery.cookie
A simple, lightweight jQuery plugin for reading, writing and deleting cookies.
If you're viewing this, you're reading the documentation for the old repository.
View documentation for the latest backwards compatible release (1.5.1).
Build Status Matrix
Installation
Include script after the jQuery library (unless you are packaging scripts somehow else):
<script src="/path/to/jquery.cookie.js"></script>
Do not include the script directly from GitHub (http://raw.github.com/...). The file is being served as text/plain and as such being blocked
in Internet Explorer on Windows 7 for instance (because of the wrong MIME type). Bottom line: GitHub is not a CDN.
The plugin can also be loaded as AMD or CommonJS module.
// Returns true when cookie was successfully deleted, otherwise false
$.removeCookie('name'); // => true
$.removeCookie('nothing'); // => false
// Need to use the same attributes (path, domain) as what the cookie was written with
$.cookie('name', 'value', { path: '/' });
// This won't work!
$.removeCookie('name'); // => false
// This will work!
$.removeCookie('name', { path: '/' }); // => true
Note: when deleting a cookie, you must pass the exact same path, domain and secure options that were used to set the cookie, unless you're relying on the default options that is.
Configuration
raw
By default the cookie value is encoded/decoded when writing/reading, using encodeURIComponent/decodeURIComponent. Bypass this by setting raw to true:
$.cookie.raw = true;
json
Turn on automatic storage of JSON objects passed as the cookie value. Assumes JSON.stringify and JSON.parse:
$.cookie.json = true;
Cookie Options
Cookie attributes can be set globally by setting properties of the $.cookie.defaults object or individually for each call to $.cookie() by passing a plain object to the options argument. Per-call options override the default options.
expires
expires: 365
Define lifetime of the cookie. Value can be a Number which will be interpreted as days from time of creation or a Date object. If omitted, the cookie becomes a session cookie.
path
path: '/'
Define the path where the cookie is valid. By default the path of the cookie is the path of the page where the cookie was created (standard browser behavior). If you want to make it available for instance across the entire domain use path: '/'. Default: path of page where the cookie was created.
Note regarding Internet Explorer:
Due to an obscure bug in the underlying WinINET InternetGetCookie implementation, IE’s document.cookie will not return a cookie if it was set with a path attribute containing a filename.
(From Internet Explorer Cookie Internals (FAQ))
This means one cannot set a path using path: window.location.pathname in case such pathname contains a filename like so: /check.html (or at least, such cookie cannot be read correctly).
domain
domain: 'example.com'
Define the domain where the cookie is valid. Default: domain of page where the cookie was created.
secure
secure: true
If true, the cookie transmission requires a secure protocol (https). Default: false.
Converters
Provide a conversion function as optional last argument for reading, in order to change the cookie's value
to a different representation on the fly.
Có — carhartl/jquery-cookie phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/carhartl/jquery-cookie.
carhartl/jquery-cookie có tag gì không?
Bản đồng bộ chưa ghi nhận topic GitHub nào cho carhartl/jquery-cookie. GitHub topics hiển thị ở thanh bên phải trang repo — đó là nơi đáng kiểm tra nhất.
carhartl/jquery-cookie có trang demo không?
Dự án có trang chủ ở https://github.com/js-cookie/js-cookie. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
carhartl/jquery-cookie còn đang phát triển không?
Commit gần nhất trên carhartl/jquery-cookie là 9.4 năm trước (theo timestamp GitHub). Repo có 3.9k fork — một chỉ báo về mức độ quan tâm của cộng đồng.
carhartl/jquery-cookie dùng license gì?
carhartl/jquery-cookie phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
Đọc thêm về carhartl/jquery-cookie ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/carhartl/jquery-cookie là nguồn chính thức.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về jquery-cookie?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về jquery-cookie.