# `HttpCookie`
[🔗](https://github.com/reisub/http_cookie/blob/v0.11.0/lib/http_cookie.ex#L1)

HTTP Cookie struct with parsing and related logic.

Implemented according to [RFC6265](https://datatracker.ietf.org/doc/html/rfc6265)

# `t`

```elixir
@type t() :: %HttpCookie{
  creation_time: DateTime.t(),
  domain: binary(),
  expiry_time: DateTime.t(),
  host_only?: boolean(),
  http_only?: boolean(),
  last_access_time: DateTime.t(),
  name: binary(),
  path: binary(),
  persistent?: boolean(),
  secure_only?: boolean(),
  value: binary()
}
```

# `expired?`

```elixir
@spec expired?(cookie :: t(), now :: DateTime.t()) :: boolean()
```

Checks if the cookie has expired.

Uses the current time if no time is provided.

# `from_cookie_string`

```elixir
@spec from_cookie_string(str :: String.t(), request_url :: URI.t(), opts :: keyword()) ::
  {:ok, t()} | {:error, atom()}
```

Creates an HttpCookie from a `Set-Cookie` header value.

## Options

- `:max_cookie_size` - maximum size of cookie string in bytes, positive integer or :infinity, default: 8_192

# `matches_url?`

```elixir
@spec matches_url?(cookie :: t(), request_url :: URI.t()) :: boolean()
```

Checks if the cookie matches the provided request url.

The check is done as specified in [RFC 6265](https://datatracker.ietf.org/doc/html/rfc6265#section-5.4).

# `to_header_value`

```elixir
@spec to_header_value(cookie :: t()) :: String.t()
```

Formats the cookie for sending in a "Cookie" header.

# `update_last_access_time`

```elixir
@spec update_last_access_time(cookie :: t(), DateTime.t()) :: t()
```

Updates the cookie last access time.

Uses the current time if no time is provided.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
