]> khamidou — GitHub mirrors - electron.git/commitdiff
:memo: add cookies doc.
authorHaojian Wu <hokein.wu@gmail.com>
Mon, 15 Jun 2015 13:52:15 +0000 (21:52 +0800)
committerHaojian Wu <hokein.wu@gmail.com>
Fri, 19 Jun 2015 02:29:18 +0000 (10:29 +0800)
docs/README.md
docs/api/cookies.md [new file with mode: 0644]

index 98b4219d343295cc97fb2a07b4c966f21c72426f..c01a748d05ee174ed60b8182f513b91ac2ffdb6c 100644 (file)
@@ -32,6 +32,7 @@ Modules for the main process:
 * [auto-updater](api/auto-updater.md)
 * [browser-window](api/browser-window.md)
 * [content-tracing](api/content-tracing.md)
+* [cookies](api/cookies.md)
 * [dialog](api/dialog.md)
 * [global-shortcut](api/global-shortcut.md)
 * [ipc (main process)](api/ipc-main-process.md)
diff --git a/docs/api/cookies.md b/docs/api/cookies.md
new file mode 100644 (file)
index 0000000..d84e871
--- /dev/null
@@ -0,0 +1,63 @@
+# cookies
+
+The `cookies` module gives you ability to query and modify cookies, an example
+is:
+
+```javascipt
+var cookies = require('cookies');
+
+// Query all cookies.
+cookies.get({}, function(error, cookies) {
+  if (error) throw error;
+  console.log(cookies);
+});
+
+// Query all cookies that are associated with a specific url.
+cookies.get({ url : "http://www.github.com" }, function(error, cookies) {
+  if (error) throw error;
+  console.log(cookies);
+});
+
+// Set a cookie with the given cookie data; may overwrite equivalent cookies if they exist.
+cookies.set({ url : "http://www.github.com", name : "dummy_name", value : "dummy"},
+    function(error, cookies) {
+        if (error) throw error;
+        console.log(cookies);
+});
+```
+
+## cookies.get(details, callback)
+
+* `details` Object
+  * `url` String - Retrieves cookies which are associated with `url`. Empty imples retrieving cookies of all urls.
+  * `name` String - Filters cookies by name
+  * `domain` String - Retrieves cookies whose domains match or are subdomains of `domains`
+  * `path` String - Retrieves cookies whose path matches `path`
+  * `secure` Boolean - Filters cookies by their Secure property
+  * `session` Boolean - Filters out session or persistent cookies.
+* `callback` Function - function(error, cookies)
+  * `error` Error
+  * `cookies` Array - array of cookie objects.
+
+## cookies.set(details, callback)
+
+* `details` Object
+  * `url` String - Retrieves cookies which are associated with `url`
+  * `name` String - The name of the cookie. Empty by default if omitted.
+  * `value` String - The value of the cookie. Empty by default if omitted.
+  * `domain` String - The domain of the cookie. Empty by default if omitted.
+  * `path` String - The path of the cookie. Empty by default if omitted.
+  * `secure` Boolean - Whether the cookie should be marked as Secure. Defaults to false.
+  * `session` Boolean - Whether the cookie should be marked as HttpOnly. Defaults to false.
+  * `expirationDate` Double -  The expiration date of the cookie as the number of seconds since the UNIX epoch. If omitted, the cookie becomes a session cookie.
+
+* `callback` Function - function(error)
+  * `error` Error
+
+## cookies.remove(details, callback)
+
+* `details` Object
+  * `url` String - The URL associated with the cookie
+  * `name` String - The name of cookie to remove
+* `callback` Function - function(error)
+  * `error` Error