Cookie Class
+ + + + +Cookie utility.
+Item Index
+ + +Methods
+ +-
+
+
- + _createCookieHashString + + + static + + + + +
- + _createCookieString + + + static + + + + +
- + _parseCookieHash + + + static + + + + +
- + _parseCookieString + + + static + + + + +
- + _setDoc + + + + + +
- + exists + + + static + + + + +
- + get + + + static + + + + +
- + getSub + + + static + + + + +
- + getSubs + + + static + + + + +
- + remove + + + static + + + + +
- + removeSub + + + static + + + + +
- + set + + + static + + + + +
- + setSub + + + static + + + + +
- + setSubs + + + static + + + + +
Methods
+ + +_createCookieHashString
+
+
+ -
+
+
-
+
+
hash+ +
+
+
Formats a cookie value for an object containing multiple values.
+Parameters:
+ +-
+
+
-
+
+
hash+ Object + + + + +++ + +An object of key-value pairs to create a string for.
+
+
+
Returns:
+ +_createCookieString
+
+
+ -
+
+
-
+
+
name+ +
+
+ -
+
+
value+ +
+
+ -
+
+
encodeValue+ +
+
+ -
+
+
options+ +
+
+
Creates a cookie string that can be assigned into document.cookie.
+Parameters:
+ +-
+
+
-
+
+
name+ String + + + + +++ + +The name of the cookie.
+
+
+ -
+
+
value+ String + + + + +++ + +The value of the cookie.
+
+
+ -
+
+
encodeValue+ Boolean + + + + +++ + +True to encode the value, false to leave as-is.
+
+
+ -
+
+
options+ Object + + + + +++ + +(Optional) Options for the cookie.
+
+
+
Returns:
+ +_parseCookieHash
+
+
+ -
+
+
-
+
+
text+ +
+
+
Parses a cookie hash string into an object.
+Parameters:
+ +-
+
+
-
+
+
text+ String + + + + +++ + +The cookie hash string to parse (format: n1=v1&n2=v2).
+
+
+
Returns:
+ +_parseCookieString
+
+
+ -
+
+
-
+
+
text+ +
+
+ -
+
+
shouldDecode+ +
+
+ -
+
+
options+ +
+
+
Parses a cookie string into an object representing all accessible cookies.
+Parameters:
+ +-
+
+
-
+
+
text+ String + + + + +++ + +The cookie string to parse.
+
+
+ -
+
+
shouldDecode+ Boolean + + + + +++ + +(Optional) Indicates if the cookie values should be decoded or not. Default is true.
+
+
+ -
+
+
options+ Object + + + + +++ + +(Optional) Contains settings for loading the cookie.
+
+
+
Returns:
+ +_setDoc
+
+
+ -
+
+
-
+
+
newDoc+ +
+
+
Sets the document object that the cookie utility uses for setting
+cookies. This method is necessary to ensure that the cookie utility
+unit tests can pass even when run on a domain instead of locally.
+This method should not be used otherwise; you should use
+Y.config.doc to change the document that the cookie
+utility uses for everyday purposes.
Parameters:
+ +-
+
+
-
+
+
newDoc+ Object + + + + +++ + +The object to use as the document.
+
+
+
Returns:
+ +exists
+
+
+ -
+
+
-
+
+
name+ +
+
+
Determines if the cookie with the given name exists. This is useful for +Boolean cookies (those that do not follow the name=value convention).
+Parameters:
+ +-
+
+
-
+
+
name+ String + + + + +++ + +The name of the cookie to check.
+
+
+
Returns:
+ +get
+
+
+ -
+
+
-
+
+
name+ +
+
+ -
+
+
options+ +
+
+
Returns the cookie value for the given name.
+Parameters:
+ +-
+
+
-
+
+
name+ String + + + + +++ + +The name of the cookie to retrieve.
+
+
+ -
+
+
options+ Function | Object + + + + +++ + +(Optional) An object containing one or more + cookie options: raw (true/false), reverseCookieLoading (true/false) + and converter (a function). + The converter function is run on the value before returning it. The + function is not used if the cookie doesn't exist. The function can be + passed instead of the options object for backwards compatibility. When + raw is set to true, the cookie value is not URI decoded.
+
+
+
Returns:
+ +getSub
+
+
+ -
+
+
-
+
+
name+ +
+
+ -
+
+
subName+ +
+
+ -
+
+
converter+ +
+
+ -
+
+
options+ +
+
+
Returns the value of a subcookie.
+Parameters:
+ +-
+
+
-
+
+
name+ String + + + + +++ + +The name of the cookie to retrieve.
+
+
+ -
+
+
subName+ String + + + + +++ + +The name of the subcookie to retrieve.
+
+
+ -
+
+
converter+ Function + + + + +++ + +(Optional) A function to run on the value before returning + it. The function is not used if the cookie doesn't exist.
+
+
+ -
+
+
options+ Object + + + + +++ + +(Optional) Containing one or more settings for cookie parsing.
+
+
+
Returns:
+ +getSubs
+
+
+ -
+
+
-
+
+
name+ +
+
+ -
+
+
options+ +
+
+
Returns an object containing name-value pairs stored in the cookie with the given name.
+Parameters:
+ + +Returns:
+ +remove
+
+
+ -
+
+
-
+
+
name+ +
+
+ -
+
+
options+ +
+
+
Removes a cookie from the machine by setting its expiration date to +sometime in the past.
+Parameters:
+ +-
+
+
-
+
+
name+ String + + + + +++ + +The name of the cookie to remove.
+
+
+ -
+
+
options+ Object + + + + +++ + +(Optional) An object containing one or more + cookie options: path (a string), domain (a string), + and secure (true/false). The expires option will be overwritten + by the method.
+
+
+
Returns:
+ +removeSub
+
+
+ -
+
+
-
+
+
name+ +
+
+ -
+
+
subName+ +
+
+ -
+
+
options+ +
+
+
Removes a sub cookie with a given name.
+Parameters:
+ +-
+
+
-
+
+
name+ String + + + + +++ + +The name of the cookie in which the subcookie exists.
+
+
+ -
+
+
subName+ String + + + + +++ + +The name of the subcookie to remove.
+
+
+ -
+
+
options+ Object + + + + +++ + +(Optional) An object containing one or more + cookie options: path (a string), domain (a string), expires (a Date object), + removeIfEmpty (true/false), and secure (true/false). This must be the same + settings as the original subcookie.
+
+
+
Returns:
+ +set
+
+
+ -
+
+
-
+
+
name+ +
+
+ -
+
+
value+ +
+
+ -
+
+
options+ +
+
+
Sets a cookie with a given name and value.
+Parameters:
+ +-
+
+
-
+
+
name+ String + + + + +++ + +The name of the cookie to set.
+
+
+ -
+
+
value+ Variant + + + + +++ + +The value to set for the cookie.
+
+
+ -
+
+
options+ Object + + + + +++ + +(Optional) An object containing one or more + cookie options: path (a string), domain (a string), expires (a Date object), + secure (true/false), and raw (true/false). Setting raw to true indicates + that the cookie should not be URI encoded before being set.
+
+
+
Returns:
+ +setSub
+
+
+ -
+
+
-
+
+
name+ +
+
+ -
+
+
subName+ +
+
+ -
+
+
value+ +
+
+ -
+
+
options+ +
+
+
Sets a sub cookie with a given name to a particular value.
+Parameters:
+ +-
+
+
-
+
+
name+ String + + + + +++ + +The name of the cookie to set.
+
+
+ -
+
+
subName+ String + + + + +++ + +The name of the subcookie to set.
+
+
+ -
+
+
value+ Variant + + + + +++ + +The value to set.
+
+
+ -
+
+
options+ Object + + + + +++ + +(Optional) An object containing one or more + cookie options: path (a string), domain (a string), expires (a Date object), + and secure (true/false).
+
+
+
Returns:
+ +setSubs
+
+
+ -
+
+
-
+
+
name+ +
+
+ -
+
+
value+ +
+
+ -
+
+
options+ +
+
+
Sets a cookie with a given name to contain a hash of name-value pairs.
+Parameters:
+ +-
+
+
-
+
+
name+ String + + + + +++ + +The name of the cookie to set.
+
+
+ -
+
+
value+ Object + + + + +++ + +An object containing name-value pairs.
+
+
+ -
+
+
options+ Object + + + + +++ + +(Optional) An object containing one or more + cookie options: path (a string), domain (a string), expires (a Date object), + and secure (true/false).
+
+
+
