A jQuery plugin for simple access to browser cookies.
cookie.js
jQuery
core.js
To create a new cookie, or update an existing one, simply pass the key and value as the first and second parameters, respectively:
// Set cookie
$.cookie(key, value);To return a cookie's value pass the key as the only parameter:
// Get Cookie
var value = $.cookie(key);To erase an existing cookie, set it to null:
// Erase Cookie
$.cookie(key, null);Set instance options by passing a valid object at initialization, or to the public defaults method.
| Name | Type | Default | Description |
|---|---|---|---|
domain |
string |
Cookie domain | |
expires |
int |
604800000 |
Time until cookie expires |
path |
string |
Cookie path |
## Methods
Methods are publicly available, unless otherwise stated.
Creates a cookie.
$.cookie(key, value, options);| Name | Type | Default | Description |
|---|---|---|---|
key |
string |
Cookie key | |
value |
string |
Cookie value | |
options |
object |
Options object |
Deletes a cookie.
$.cookie(key, null);| Name | Type | Default | Description |
|---|---|---|---|
key |
string |
Cookie key |
Returns a cookie's value, or null.
var value = $.cookie(key);| Name | Type | Default | Description |
|---|---|---|---|
key |
string |
Cookie key |