gleam/http/cookie

Types

Attributes of a cookie when sent to a client in the set-cookie header.

pub type Attributes {
  Attributes(
    max_age: Option(Int),
    domain: Option(String),
    path: Option(String),
    secure: Bool,
    http_only: Bool,
    same_site: Option(SameSitePolicy),
  )
}

Constructors

  • Attributes(
      max_age: Option(Int),
      domain: Option(String),
      path: Option(String),
      secure: Bool,
      http_only: Bool,
      same_site: Option(SameSitePolicy),
    )

Policy options for the SameSite cookie attribute

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite

pub type SameSitePolicy {
  Lax
  Strict
  None
}

Constructors

  • Lax
  • Strict
  • None

Functions

pub fn defaults(scheme: Scheme) -> Attributes

Helper to create sensible default attributes for a set cookie.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#Attributes

pub fn parse(cookie_string: String) -> List(#(String, String))

Parse a list of cookies from a header string. Any malformed cookies will be discarded.

pub fn set_header(
  name: String,
  value: String,
  attributes: Attributes,
) -> String
Search Document