new pxlCookie(verboseopt, prefixopt, pathopt, expirationopt)
- Description:
CookieManager class for managing browser cookies with a specific prefix.
Provides methods to read, write, clear, and check the existence of cookies.
Handles value serialization, expiration, and path management.Use this class if you want to store user data between sessions.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
verbose |
boolean |
<optional> |
false
|
Enable verbose logging. |
prefix |
string |
<optional> |
"pxlNav-"
|
Prefix to prepend to all cookie names. |
path |
string |
<optional> |
"/"
|
Path for which the cookie is valid. |
expiration |
number |
<optional> |
30
|
Number of days until the cookie expires. |
Classes
Methods
(static) addDictionary(cDict)
- Description:
Adds multiple cookies from a dictionary.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cDict |
Object | Dictionary of key-value pairs to add as cookies. |
(static) clearCookie(cNameopt)
- Description:
Clears a specific cookie or all managed cookies.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
cName |
string | Array.<string> |
<optional> |
Cookie name(s) (without prefix) to clear. If omitted, clears all managed cookies. |
(static) evalCookie(cNameopt) → {boolean}
- Description:
Evaluates the existence or value of cookies with the given suffix.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
cName |
string |
<optional> |
Cookie name (without prefix). If omitted, evaluates all managed cookies. |
Returns:
True if the cookie(s) exist.
- Type
- boolean
(static) getClearCookieRegexp(cName) → {RegExp}
- Description:
Returns a RegExp to match cookies for clearing.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cName |
string | Cookie name (with or without prefix). |
Returns:
Regular expression for matching the cookie to clear.
- Type
- RegExp
(static) getExpiration() → {string}
- Description:
Returns the expiration string for a new cookie.
- Source:
Returns:
Expiration string for the cookie.
- Type
- string
(static) getRegexp(cName) → {RegExp}
- Description:
Returns a RegExp to match cookies with the given name.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cName |
string | Cookie name (with or without prefix). |
Returns:
Regular expression for matching the cookie.
- Type
- RegExp
(static) hasCookie(cName) → {boolean}
- Description:
Checks if a cookie exists.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cName |
string | Cookie name (without prefix). |
Returns:
True if the cookie exists.
- Type
- boolean
(static) isEqual(cName) → {boolean}
- Description:
Checks if the value of a cookie is equal to a given input.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cName |
string | Cookie name (without prefix). |
Returns:
True if the cookie value matches the input.
- Type
- boolean
(static) parseCookie(cName) → {string|number|boolean|null}
- Description:
Reads and parses the value of a cookie.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cName |
string | Cookie name (without prefix). |
Returns:
Parsed value of the cookie.
- Type
- string | number | boolean | null
(static) parseDict(cDict) → {boolean}
- Description:
Parses and updates a dictionary with values from cookies if they exist.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cDict |
Object | Dictionary to update with cookie values. |
Returns:
True if any items in the dictionary were set from cookies.
- Type
- boolean
(static) pullData() → {Object}
- Description:
Reads all cookies managed by this CookieManager.
- Source:
Returns:
Dictionary of cookie names and their values.
- Type
- Object
(static) readCookie(cName) → {string|null}
- Description:
Reads the value of a cookie as a string.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cName |
string | Cookie name (without prefix). |
Returns:
Value of the cookie, or null if not found.
- Type
- string | null
(static) setCookie(cName, cData)
- Description:
Sets a cookie value.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
cName |
string | Cookie name (without prefix). |
cData |
any | Value to store in the cookie. |
(static) valueToString(val) → {string}
- Description:
Converts a given value to a string representation.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
val |
any | Value to convert. |
Returns:
String representation of the value.
- Type
- string
(static) variableToString(arr) → {string}
- Description:
Converts a variable (including arrays) to a string representation.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
arr |
any | Variable or array to convert. |
Returns:
String representation of the variable.
- Type
- string