CookieJar (cookie_jar v1.1.0) View Source

CookieJar is here to store your cookie

Link to this section 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

Link to this section Functions

See CookieJar.to_string/1.

See CookieJar.to_string/2.

See CookieJar.start_link/1.

Specs

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"}

Specs

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

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

Specs

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}
Link to this function

pour(jar, cookie_strs, uri_str)

View Source

Specs

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

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

Specs

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"

Specs

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"

See CookieJar.stop/1.

Specs

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

Create a new cookie jar

Examples

CookieJar.start_link
# or
CookieJar.new

Specs

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

Specs

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"

Specs

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

Get the cookies in Cookie format for the given URI