-
Notifications
You must be signed in to change notification settings - Fork 0
Common: Cookie
✌ Makis Tracend edited this page May 24, 2013
·
7 revisions
A generic cookie parser that offers a simplified REST-like API
initialize by copying the the
var cookie = c.cookie();
Use the methods on the cookie objects to execute operations...
Sets a cookie value cookie onto the collection and the document.cookie property. Returns a boolean as a result of the operation.
This method accepts a single object that should include all information about the cookie to be set. Properties on this object:
- name (string) Required. The name of the cookie
- value (string) Required. The value of this cookie
- path (string) Optional. The path of this cookie
- domain (string) Optional. The domain of this cookie
- expires (Object) Optional. Set the expiration date of this cookie. Accepted keys:
minutes, hours, days, weeks, months, years
cookie.set({
name: "cookiename",
value: "authenticated",
expires: {
days: 1
}
});
Returns the string value of a cookie. Returns a string with the passed arguments.
- name (string) Required. The name of the cookie.
cookie.get("cookiename");
Checks for the existence of a cookie on the collection, updating the collection if it's not found. Returns a boolean.
- name (string) Required. The name of the cookie.
cookie.has("cookiename");
Deletes a cookie from the collection and updates the document object. Returns a boolean.
- name (string) Required. The name of the cookie.
cookie.remove("cookiename");