View Source CookieJar (cookie_jar v1.1.0)

CookieJar is here to store your cookie

Summary

Functions

See what's in the cookie jar, the individual cookies

See what's in the cookie jar, the individual cookies available to a URI

Pour cookies into a cookie jar

Pour cookies into a cookie jar, using cookie strings and a uri string

Put cookie into a cookie jar

Put new cookie into a cookie jar

Create a new cookie jar

Destroy a cookie jar

Get the cookies in Cookie format

Get the cookies in Cookie format for the given URI

Functions

label(jar)

See CookieJar.to_string/1.

label(jar, uri_str)

See CookieJar.to_string/2.

new(opts \\ [])

See CookieJar.start_link/1.

peek(jar)

@spec peek(GenServer.server()) :: map()

See what's in the cookie jar, the individual cookies

Examples

iex> {:ok, jar} = CookieJar.new
iex> CookieJar.peek(jar)
%{}
iex> CookieJar.put(jar, {"name", "john doe"})
iex> CookieJar.peek(jar)
%{"name" => "john doe"}

peek(jar, uri_str)

@spec peek(GenServer.server(), String.t()) :: map()

See what's in the cookie jar, the individual cookies available to a URI

pour(jar, cookies)

@spec pour(GenServer.server(), list() | map()) :: :ok

Pour cookies into a cookie jar

Examples

iex> {:ok, jar} = CookieJar.new
iex> CookieJar.peek(jar)
%{}
iex> CookieJar.pour(jar, %{"a" => 1, "b" => 2})
iex> CookieJar.peek(jar)
%{"a" => 1, "b" => 2}

pour(jar, cookie_strs, uri_str)

@spec pour(GenServer.server(), list(), String.t()) :: :ok

Pour cookies into a cookie jar, using cookie strings and a uri string

put(jar, cookie)

@spec put(GenServer.server(), CookieJar.Cookie.t() | {term(), term()}) :: :ok

Put cookie into a cookie jar

Examples

iex> {:ok, jar} = CookieJar.new
iex> CookieJar.peek(jar)
%{}
iex> CookieJar.put(jar, {"a", 1})
iex> CookieJar.put(jar, {"b", 2})
iex> CookieJar.to_string(jar)
"a=1; b=2"

put_new(jar, cookie)

@spec put_new(GenServer.server(), CookieJar.Cookie.t() | {term(), term()}) :: :ok

Put new cookie into a cookie jar

Examples

iex> {:ok, jar} = CookieJar.new
iex> CookieJar.peek(jar)
%{}
iex> CookieJar.put(jar, {"a", 1})
iex> CookieJar.put_new(jar, {"a", 3})
iex> CookieJar.to_string(jar)
"a=1"

smash(jar)

See CookieJar.stop/1.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Create a new cookie jar

Examples

CookieJar.start_link
# or
CookieJar.new

stop(jar)

@spec stop(GenServer.server()) :: :ok

Destroy a cookie jar

Examples

CookieJar.stop(jar)
# or
CookieJar.smash(jar)

iex> {:ok, jar} = CookieJar.new
iex> CookieJar.stop(jar)
iex> Process.alive?(jar)
false

to_string(jar)

@spec to_string(GenServer.server()) :: String.t()

Get the cookies in Cookie format

Examples

CookieJar.to_string(jar)
# or
CookieJar.label(jar)

iex> {:ok, jar} = CookieJar.new
iex> CookieJar.to_string(jar)
""
iex> CookieJar.put(jar, {"a", 1})
iex> CookieJar.put(jar, {"b", 2})
iex> CookieJar.to_string(jar)
"a=1; b=2"

to_string(jar, uri_str)

@spec to_string(GenServer.server(), String.t()) :: String.t()

Get the cookies in Cookie format for the given URI