Attention! You must install the http-cookie gem to use this feature.

The cookies plugin seamlessly creates the concept of a stateful session, i.e. all requests flowing through it will share and update the cookie store.

A user can also pass the initial set of cookies when starting the session, though.

How to pass cookies:

http = HTTPX.plugin(:cookies)
http.cookies("foo" => "bar").get("")

But this is the ideal scenario:

http = HTTPX.plugin(:cookies)
response = http.get("") #=> "302 ... Location: ... Set-Cookie: aadm...."
response = http.get(response.headers["location"]) => Sends the cookie information

This plugin also works seamlessly with the follow_redirects plugin, in the redirections setting a session cookie will be respected:

http = HTTPX.plugin(:cookies, :follow_redirects)
response = http.get("") #=> will redirect to "" and set the cookie

Next: Compression