View Source HttpCookie.Jar (http_cookie v0.6.0)

Summary

Functions

Removes cookies which expired before the provided time from the jar.

Removes session cookies from the jar.

Gets all the cookies in the store which match the given request URL.

Creates a new empty cookie jar.

Stores the provided cookie in the jar.

Stores the provided cookies in the jar.

Processes the response header list for the given request URL. Parses set-cookie/set-cookie2 headers and stores valid cookies.

Types

@type t() :: %HttpCookie.Jar{cookies: [HttpCookie.t()], opts: keyword()}

Functions

Link to this function

clear_expired_cookies(jar, now \\ DateTime.utc_now())

View Source
@spec clear_expired_cookies(
  jar :: %HttpCookie.Jar{cookies: term(), opts: term()},
  now :: DateTime.t()
) ::
  %HttpCookie.Jar{cookies: term(), opts: term()}

Removes cookies which expired before the provided time from the jar.

Uses the current time if no time is provided.

Link to this function

clear_session_cookies(jar)

View Source
@spec clear_session_cookies(jar :: %HttpCookie.Jar{cookies: term(), opts: term()}) ::
  %HttpCookie.Jar{
    cookies: term(),
    opts: term()
  }

Removes session cookies from the jar.

Cookies which don't have an explicit expiry time set are considered session cookies and they expire when a user session ends.

Link to this function

get_matching_cookies(jar, request_url)

View Source
@spec get_matching_cookies(
  jar :: %HttpCookie.Jar{cookies: term(), opts: term()},
  request_url :: URI.t()
) :: [HttpCookie.t()]

Gets all the cookies in the store which match the given request URL.

@spec new(opts :: keyword()) :: %HttpCookie.Jar{cookies: term(), opts: term()}

Creates a new empty cookie jar.

Options

  • :reject_public_suffixes - controls whether to reject public suffixes to guard against "supercookies", defaults to true
@spec put_cookie(
  jar :: %HttpCookie.Jar{cookies: term(), opts: term()},
  cookie :: HttpCookie.t()
) ::
  %HttpCookie.Jar{cookies: term(), opts: term()}

Stores the provided cookie in the jar.

Link to this function

put_cookies(jar, cookies)

View Source
@spec put_cookies(
  jar :: %HttpCookie.Jar{cookies: term(), opts: term()},
  cookies :: [HttpCookie.t()]
) ::
  %HttpCookie.Jar{cookies: term(), opts: term()}

Stores the provided cookies in the jar.

Link to this function

put_cookies_from_headers(jar, request_url, headers)

View Source
@spec put_cookies_from_headers(jar :: t(), request_url :: URI.t(), headers :: list()) ::
  t()

Processes the response header list for the given request URL. Parses set-cookie/set-cookie2 headers and stores valid cookies.