cookie name
cookie value
Optional
options: { Optional
domain?: stringA String indicating a valid domain where the cookie should be visible. The cookie will also be visible to all subdomains.
Optional
expires?: numberExpire cookie after x days (negative to remove cookie)
Optional
path?: stringA String indicating the path where the cookie is visible.
Optional
sameA String, allowing to control whether the browser is sending a cookie along with cross-site requests.
Optional
secure?: booleanA Boolean indicating if the cookie transmission requires a secure protocol (https).
// Create a cookie, valid across the entire site:
document.cookie = generateCookie('name', 'value')
// Create a cookie that expires 7 days from now, valid across the entire site:
document.cookie = generateCookie('name', 'value', { expires: 7 })
// Delete a cookie by setting the expires parameter to zero:
document.cookie = generateCookie('name', 'value', { expires: 0 })
Generates cookie string