Skip to content

CookieJar stores your cookies and applies them to future requests

License

Notifications You must be signed in to change notification settings

princemaple/cookie_jar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CookieJar

hex.pm version API Docs

COOKIE JAR

Installation

The package can be installed by adding cookie_jar to your list of dependencies in mix.exs:

def deps do
  [{:cookie_jar, "~> 1.0"}]
end

Usage

  1. Add alias (optional)
alias CookieJar.HTTPoison, as: HTTPoison
  1. Get a cookie jar
{:ok, jar} = CookieJar.new

Alternatively, you can use a permenent cookie jar by starting one as part of your supervision tree:

def start(_type, _args) do
  children = [
  {CookieJar.Server, name: MyApp.CookieJar},
  ...

Then you can use MyApp.CookieJar as the application-wide jar.

  1. Shove the jar into all http calls
- HTTPoison.get("https://example.com/api/call")
+ HTTPoison.get(jar, "https://example.com/api/call")
  1. Profit (cookies imprisoned) All cookies from "Set-Cookie:" response headers are now stored in the jar and will be automatically sent back through "Cookie:" request headers. CookieJar respect the following attributes in the cookies:
  • Domain: To limit abuses, CookieJar only allows Domain to be set to the current hostname of the request or its immediate parent domain.
  • Path: A cookie can limit the sending back to part of the path tree in the request
  • Secure: A secure cookie can only be set by https responses and used by https requests
  • Max-Age: A cookie can specify its max age

All other attributes are silently ignored.

Take a look at the docs

About

CookieJar stores your cookies and applies them to future requests

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages