Takes the name of a cookie and sets its value.

This function is valid in v2.24.2. This function has been downloaded 7 times.


{string} name
Name of the cookie to set.
{string} value
Value of the cookie to set. If not a string, it will be coerced into a string.
{Object=} opt_options Optional, Default:{path:'/'}
Object whose property values can be used to specify additional options. If the cookie is meant to expire at a certain time you can set the expires property to a Date object or the number representation of such a date. If you want to specify the maximum amount of seconds until the cookie expires you can set the maxAge (or max-age) property to the number of seconds. If you want to specify the hosts to which the cookie will be sent you can set the domain property. If a domain is specified, subdomains are always included. If you want to specify the URL path that under which the cookie will be saved you can specify it in the path property. If you want to set a secure cookie while on a secure site (https:) you can set the secure property to true. If you want to set the same site option to "none", "lax" or "strict" you can specify one of those strings as the value for the samesite property (or the sameSite property).


Boolean indicating whether or not the cookie was set.

Required Function

This function directly requires the following function which is included automatically:

  • hasCookie()
    Determines if there is a cookie with the specified name.

Requiring Function

This function is directly required by the following function: