MCPcopy
hub / github.com/remix-run/remix / Cookie

Class Cookie

packages/cookie/src/lib/cookie.ts:50–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48 * secret rotation to easily rotate secrets without breaking existing cookies.
49 */
50export class Cookie implements CookieProperties {
51 #name: string
52 #decode: Coder
53 #encode: Coder
54 #secrets: string[]
55 #domain: string | undefined
56 #expires: Date | undefined
57 #httpOnly: boolean | undefined
58 #maxAge: number | undefined
59 #partitioned: boolean | undefined
60 #path: string
61 #sameSite: SameSiteValue
62 #secure: boolean | undefined
63
64 /**
65 * @param name The name of the cookie
66 * @param options Options for the cookie
67 */
68 constructor(name: string, options?: CookieOptions) {
69 let {
70 decode = decodeURIComponent,
71 encode = encodeURIComponent,
72 secrets = [],
73 domain,
74 expires,
75 httpOnly,
76 maxAge,
77 path = '/',
78 partitioned,
79 secure,
80 sameSite = 'Lax',
81 } = options ?? {}
82
83 if (partitioned === true) {
84 // Partitioned cookies must be set with Secure
85 // See https://developer.mozilla.org/en-US/docs/Web/Privacy/Guides/Privacy_sandbox/Partitioned_cookies
86 secure = true
87 }
88
89 this.#name = name
90 this.#decode = decode
91 this.#encode = encode
92 this.#secrets = secrets
93 this.#domain = domain
94 this.#expires = expires
95 this.#httpOnly = httpOnly
96 this.#maxAge = maxAge
97 this.#partitioned = partitioned
98 this.#path = path
99 this.#sameSite = sameSite
100 this.#secure = secure
101 }
102
103 /**
104 * The domain of the cookie.
105 *
106 * [MDN Reference](https://developer.mozilla.org/en-US/Web/HTTP/Headers/Set-Cookie#domaindomain-value)
107 */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…