Started

Selectors

Utilities

Animation

AJAX

CSS

Event

Manipulation

Cookie

String

Attributes

Data

Storage

Miscellaneous

$cookie.set

Set cookie data.
$cookie.set( key, value ) or $cookie.set( object )
  1. key [string]
    The key name of data saved in cookie.
  2. value [string]
    The value of data saved in cookie.
  3. object [object]
    The object with key name and value.

Notes

The common function to set data from cookie. It also allowed to storage Array and Object as value.

Example

HTML code
<div id="message"></div>
<button onclick="start_cookie_set()">Save "Hello" into cookie as name "data".</button>
<button onclick="start_cookie_get()">Get "data" from cookie</button>
<button onclick="start_cookie_remove()">Remove "data" from cookie</button>
JavaScript code
function start_cookie_get()
{
	$html($("message"), "The value of 'data' in cookie is '" + $cookie.get("data") + "' and the value of 'foo' is '" + $cookie.get("foo") + "'");
}

function start_cookie_set()
{
	$cookie.set("data", "Hello");
	$cookie.set({
		"world": "Hello",
		"foo": "bar"
	});

	$html($("message"), "The value is saved into cookie!");
}

function start_cookie_remove()
{
	$cookie.remove("data", "world", "foo");
	$html($("message"), "The value 'Hello' of 'data' is removed from cookie!");
}
Demonstration