Cookies

Here is the documentation for Cookie.js.

The Cookie object, does pretty much what you'd expect. It has three functions:

Cookie.write

//let's store "example" as "some value" for 10 days
Cookie.write("example", "some value", {duration: 10});

You can set three (optional) options in the 3rd argument:

Cookie.write("example", "some value", {
	duration: 10, //ten days
	path: "/some/path", //now my cookie is available to
	//only content in this path
	domain: "example.com", //now my cookie is available to any
	//subdomains of example.com,
	secure: true //stored cookie information 
	//can be accessed only from a secure environment
});

Cookie.read

//let's get it now
Cookie.read("example"); // -> "some value"

Cookie.dispose

Cookie.dispose("example"); //delete the cookie

Deprecated Methods

  • Cookie.get (see Cookie.read)
  • Cookie.set (see Cookie.write)
  • Cookie.remove (see Cookie.dispose)

mootorial/05-utilities/03-cookie.txt · Last modified: 2008/10/27 23:53