Dough is an easy to use cookie plugin for jQuery with powerful features. Dough can auto set your domain name with ‘.’ prefix so your cookies work with subdomains and will allow you to easily go from local to staging to product servers with out a problem.
Developed by Nathan Searles, http://nathansearles.com
For updates, follow Nathan Searles on Twitter
Dough is licensed under the Apache license.
Check out an example at http://nathansearles.com/plugin/dough/
Note: If setting the path to “current”, you must also define that when removing the cookie.
$.dough("cookieName", "remove", { path: "current" });
Set full cookie
$.dough("cookieName", "cookieValue", { expires: 365, path: "current", domain: "auto", secure: true });
Example cookie has a name of “cookieName”, a value of “cookieValue”, will expire in 1 year, have path of current page, domain will be autodetected and is set to secure for a use under https://.
Create JSON cookie
$.dough("jsonCookie", "{'someName':'someValue','someOtherName':'someOtherValue'}");
That will return ‘someValue’
- expires: Days ’til cookie expires
- path: Default is root ‘/’, set to ‘current’ to use the path of current page
- domain: Auto detect and set domain with subdomain prefix
- secure: Set to true if you’re using https://
- 1.3
- Fixed: issue with JSON detection
- 1.2
- Fixed: issue with auto domain detection
- Cleaned up a few things
- 1.1
- New: Support for JSON in cookie value
- 1.0
- Initial release