---
title: "Cookie"
source: "https://github.com/remix-run/remix/blob/8905f3943706e1f53696ab83e70a84873cabfc90/packages/cookie/src/lib/cookie.ts#L50"
---

# Cookie

## Summary

Represents a HTTP cookie.

Supports parsing and serializing the cookie to/from `Cookie` and `Set-Cookie` headers.

Also supports cryptographic signing of the cookie value to ensure it's not tampered with, and
secret rotation to easily rotate secrets without breaking existing cookies.

## Signature

```ts
class Cookie {
  constructor(name: string, options: CookieOptions): Cookie

  // Accessors
  get domain(): string | undefined
  get expires(): Date | undefined
  get httpOnly(): boolean | undefined
  get maxAge(): number | undefined
  get name(): string
  get partitioned(): boolean
  get path(): string
  get sameSite(): SameSiteValue
  get secure(): boolean | undefined
  get signed(): boolean

  // Methods
  parse(headerValue: string | null): Promise<string | null>
  serialize(value: string, props: CookieProperties): Promise<string>
}

```

## Constructor

### Parameters

#### `name`

The name of the cookie

#### `options`

Options for the cookie

## Accessors

### `domain`

The domain of the cookie.

[MDN Reference](https://developer.mozilla.org/en-US/Web/HTTP/Headers/Set-Cookie#domaindomain-value)

### `expires`

The expiration date of the cookie.

[MDN Reference](https://developer.mozilla.org/en-US/Web/HTTP/Headers/Set-Cookie#expiresdate)

### `httpOnly`

Whether the cookie is HTTP-only, or `undefined` when the option was not configured.

[MDN Reference](https://developer.mozilla.org/en-US/Web/HTTP/Headers/Set-Cookie#httponly)

### `maxAge`

The maximum age of the cookie in seconds.

[MDN Reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#max-agenumber)

### `name`

The name of the cookie.

[MDN Reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#cookie-namecookie-value)

### `partitioned`

True if the cookie is partitioned.

[MDN Reference](https://developer.mozilla.org/en-US/Web/HTTP/Headers/Set-Cookie#partitioned)

### `path`

The path of the cookie.

[MDN Reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#pathpath-value)

### `sameSite`

The `SameSite` attribute of the cookie, normalized to `Strict`, `Lax`, or `None`.

[MDN Reference](https://developer.mozilla.org/en-US/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value)

### `secure`

Whether the cookie is only sent over HTTPS, or `undefined` when not configured.

[MDN Reference](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#secure)

### `signed`

True if this cookie uses one or more secrets for verification.

## Methods

### `parse(headerValue: string | null): Promise<string | null>`

Extracts the value of this cookie from a `Cookie` header value.

#### Parameters

##### `headerValue`

The `Cookie` header to parse

### `serialize(value: string, props: CookieProperties): Promise<string>`

Returns the value to use in a `Set-Cookie` header for this cookie.

#### Parameters

##### `value`

The value to serialize

##### `props`

Additional properties to use when serializing the cookie