1 Object: Cookie {#Cookie}
2 ========================
4 Sets and accesses cookies.
8 - Based on the functions by Peter-Paul Koch [QuirksMode][].
10 ### Options: {#Cookie-options}
12 * domain - (*string*: defaults to false) The domain the Cookie belongs to.
13 * path - (*string*: defaults to false) The path the Cookie belongs to.
14 * duration - (*number*: defaults to false) The duration of the Cookie before it expires, in days. If set to false or 0, the cookie will be a session cookie that expires when the browser is closed.
15 * secure - (*boolean*: defaults to false) Stored cookie information can be accessed only from a secure environment.
19 - In order to share the Cookie with pages located in a different path, the [Cookie.options.domain][] value must be set.
23 Cookie Method: write {#Cookie:write}
24 --------------------------------
26 Writes a cookie in the browser.
30 var myCookie = Cookie.write(key, value[, options]);
34 1. key - (*string*) The key (or name) of the cookie.
35 2. value - (*string*) The value to set. Cannot contain semicolons.
36 3. options - (*mixed*, optional) See [Cookie][].
40 * (*object*) An object with the options, the key and the value. You can give it as first parameter to Cookie.remove.
44 Saves the Cookie for the Duration of the Session:
46 var myCookie = Cookie.write('username', 'Harald');
48 Saves the Cookie for a Day:
50 var myCookie = Cookie.write('username', 'JackBauer', {duration: 1});
54 Cookie Method: read {#Cookie:read}
55 --------------------------------
57 Reads the value of a Cookie.
61 var myCookie = Cookie.read(name);
65 1. name - (*string*) The name of the Cookie to retrieve.
69 * (*mixed*) The cookie string value, or null if not found.
73 Cookie.read("username");
77 Cookie Method: dispose {#Cookie:dispose}
78 --------------------------------------
80 Removes a cookie from the browser.
84 var oldCookie = Cookie.dispose(cookie[, options]);
88 1. name - (*string*) The name of the cookie to remove or a previously saved Cookie instance.
89 2. options - (*object*, optional) See [Cookie][].
95 Cookie.dispose('username'); //Bye-bye JackBauer! Seeya in 24 Hours.
97 Creating a Cookie and Removing it Right Away:
99 var myCookie = Cookie.write('username', 'Aaron', {domain: 'mootools.net'});
100 if (Cookie.read('username') == 'Aaron') { Cookie.dispose(myCookie); }
105 [Cookie.options]: #Cookie-options
106 [Cookie.options.domain]: #Cookie-options
107 [QuirksMode]: http://www.quirksmode.org