Takes the name of a cookie and sets its value.

This function is valid in v2.0.0 to v2.17.1. This function has been downloaded 12 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.


Boolean indicating whether or not the cookie was set.

Required Function

This function requires the following function which is included automatically:

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