@trashpanda001/helpers
    Preparing search index...

    Function setCookie

    • 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.

      Parameters

      • name: string

        the cookie name

      • value: string

        the cookie value

      • options: Readonly<CookieOptions> = {}

        cookie options

      Returns void

      Error if called during SSR

      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