This API saves a browser cookie.
Parameters:
- name - the name of the cookie
- value - the value to place in the cookie
- expires - optional number of days from now that the cookie will expire in; if not specified, the cookie only lasts for the duration of a browser session and is removed when the browser is closed
- path - optional URL path on the server in which the cookie will be available on; if set to '/', the cookie will be available within the entire domain; if set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain; the default value is the current directory that the cookie is being set in
- domain - optional domain name that the cookie is available to; setting the domain to 'www.example.com' will make the cookie available in the www subdomain and higher subdomains. Cookies available to a lower domain, such as 'example.com' will be available to higher subdomains, such as 'www.example.com'
- secure - optional true or false value indicating that the cookie should only be transmitted over a secure HTTPS connection. When set to true, the cookie will only be set if a secure connection exists.
Example:
The following code saves the current user to a cookie that will expire in 30 days:
pui.setCookie("user", currentUser, 30);
The following code saves a cookie that will expire in 1 hour:
pui.setCookie("active", "1", 1/24);