the cookie name
the cookie value
cookie options
import { setCookie } from "@trashpanda001/helpers/cookie"
setCookie("foo", "bar")
// Set-Cookie: foo=bar; Path=/; Secure; Same-Site=Lax; Max-Age=34560000
setCookie("foo", "bar", { maxAge: 3600 })
// Set-Cookie: foo=bar; Path=/; Secure; Same-Site=Lax; Max-Age=3600
setCookie("foo", "bar", { maxAge: "session" })
// Set-Cookie: foo=bar; Path=/; Secure; Same-Site=Lax
setCookie("foo", "bar", { domain: "example.com" })
// Set-Cookie: foo=bar; Domain=example.com; Path=/; Secure; Same-Site=Lax; Max-Age=34560000
Set a cookie to the given value.
Assumes the cookie name is a valid cookie token and URI encodes the value. If the value is an empty string, the cookie is deleted. The cookie is not HTTP-only, so it can be accessed from JavaScript.