# Adding cookies net/http

**URL:** https://rubytalk.org/t/adding-cookies-net-http/62063
**Category:** ruby-talk
**Created:** [8 March 2011 13:08 UTC](https://rubytalk.org/t/adding-cookies-net-http/62063 "2011-03-08T13:08:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Mario\_Ruiz1](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@Mario\_Ruiz1](https://rubytalk.org/u/Mario_Ruiz1)
#### Post date: [8 March 2011 13:08 UTC](https://rubytalk.org/t/adding-cookies-net-http/62063/1 "2011-03-08T13:08:56Z")

</div>

Hi,  
when I call different pages I get on response ["set-cookie"] so i need  
to add the new cookies to my http connection by doing:

headers={'Cookie'=\>resp.response["set-cookie"]}

and then when I call post or get methods pass my headers

But when I give the new cookies I think I'm missing the old ones, how  
can I keep all cookies on my connection?

Thanks

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

### Author: ![7stud](https://avatars.discourse-cdn.com/v4/letter/7/57b2e6/32.png) [@7stud](https://rubytalk.org/u/7stud)
#### Post date: [8 March 2011 18:14 UTC](https://rubytalk.org/t/adding-cookies-net-http/62063/2 "2011-03-08T18:14:27Z")

</div>

How about using Mechanize, which automatically stores cookies and adds  
them to requests?

If you want to do it by hand yourself, check out this post:

> <https://stackoverflow.com/questions/1486703/how-to-implement-cookie-support-in-ruby-net-http>

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
