- Source:
Methods
setCookie(name, valueopt, nullable, optionsopt, nullable) → {String|null}
Set a cookie value (if possible) by name. Value will automatically be encoded.
If you set a cookie to a nullish value, the method will try to remove the cookie with the given options.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
String | the name of the cookie to set |
|
value |
String |
<optional> <nullable> |
the value of the cookie to set |
options |
Cookies.CookieOptions |
<optional> <nullable> |
the cookie options to apply |
- Source:
- See:
Returns:
returns the set cookie value if available after setting or null if cookie not available (which would also mean, that setting the cookie did not work, or, in case of removal, that the removal worked)
- Type
- String | null
Example
setCookie('mykittencookie', 'meow meow', {expires : 7, path : '/kittens', secure : true, samesite : 'strict'});