addCookie
Adds a cookie.
See Set-Cookie at mdn for details about the parameters used.
addCookie(name, value, path, domain, expiry, isSecure, isHttpOnly)
#
Parametersname
: Required. Cookie name asstring
.value
: Required. Cookie value asstring
.path
: Optional. Path where the cookie can be accessed asstring
. Defaults to/
.domain
: Optional. Host name where cookie is accessible asstring
. Defaults to current url's host.expiry
: Optional. Milliseconds since current time when the cookie should expire. For example, to set a cookie for expiration in 365 days, provide365 * 24 * 60 * 60 * 1000
. If omitted, cookie deletes once browser is closed.isSecure
: Optional. Value indicating whether cookie is sent to server only inhttps
connection asboolean
. Defaults tofalse
.isHttpOnly
: Optional. Value indicating whetherjs
can access this cookie asboolean
. Defaults tofalse
.
#
Returns- No value
#
Example# set a cookie for expiration in an houraddCookie('some-cookie', '1118;accepted', '/', 'example.com', 60*60*1000, true)