From: Ben Johnson Date: 2006-07-15T07:37:23+09:00 Subject: Handling cookies with Net::HTTP? --Apple-Mail-4-663258424 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed I am having a strange problem and it is partly due to my poor understanding of cookies. So any help is greatly appreciated. I am trying to navigate through a site which requires that I provide them with the cookies they send me. I am having some trouble here. I am grabbing the 'set-cookie' header they send back to me and storing each cookie in a hash like: cookies[name] = value. Here is the code I wrote for that: def parse_cookie(set_cookie) # Attempt to pull out SID, BID, CID @cookies ||= {} ['SID', 'BID', 'CID'].each do |var| cookie = set_cookie.scan(/(#{var}=.*?);/) cookie = cookie.join('').split('=') @cookies[cookie[0]] = cookie[1] unless cookie.size != 2 end end I only want the SID, BID, and CID cookies. Then when I send another request to them I am doing the following: def cookies cookie_str = '' @cookies.each do |k, v| unless cookie_str == '' cookie_str << ';' end cookie_str << k << '=' << v end unless @cookies.nil? cookie_str end req.add_field 'Cookie', cookies #this calls the above method Which ended up sending the following 'Cookie' header: SID=VpI2zrrUjHDufXLqUec5VEWPia-JgWWQH3k- DPOxEhOKcvtZh46eZxw2xrAwK5N645v3B4oRAtoI0b8_;BID=bWtbrEQbrPcZmyvFQoXsZoq qWYrhV81w1698hx5-e1NUQZqE-tg9K9K36pt_CFIXcuW- FOkplULieRehl4t5;CID=tSqTx-fWLck-ncBcWaZNUNo-XhTUc- lM0xyHTe1VDmrZzVrMty0u3qSeAw4uTA6eW6Kl Am I not sending the cookie header properly, because the site is not accepting them. Do I need to include more information than just the name and the value? Thanks for your help. Thank You, Ben Johnson E: bjohnson@contuitive.com --Apple-Mail-4-663258424--