Sets a cookie on the current page.

Basic Usage

UI.COOKIE.set(name, value)


UI.COOKIE.set("foo", "bar")

This sets a cookie named "foo" with the value "bar" on the page "https://google.com".

Advanced Usage

You can set more properties of the cookie using an options object.



Not sure what are these options? Learn more about HTTP Cookies from MDN.

Option Type Description
name string Required.
Name of the cookie
value string Required.
Value of the cookie
secure boolean Set a Secure cookie.
Secure cookies cannot be set on insecure http: sites.

Default: false
httpOnly boolean Set an HttpOnly cookie.

Default: false
domain string Domain to apply the cookie to.
Can only be set to domains for the current page.
Examples: example.com, support.example.com

Default: Domain of the current page
path string Path to apply the cookie to.

Default: \
maxAge number Number of seconds until this cookies expires
expires string Time when cookie expires.
Ignored if maxAge is also provided.
Example: Wed, 21 Oct 2015 07:28:00 GMT


    name: "foo", 
    value: "bar", 
    secure: true, 
    maxAge: 86400 

Sets a Secure cookie foo with the value bar that expires in 86400 seconds at the current page.