views:

115

answers:

1

I am programmatcally accessing authenticated content in my CDN on Google App Engine, and it's returning a cookie that I'm supposed to store:

{"set-cookie"=>"ACSID=cookie-hash; expires=Mon, 12-Apr-2010 01:56:06 GMT; path=/"}

What do I do with that? This is my first time dealing with Cookies.

I can put in the header of the next request, but what's the recommended way to store that? I'm testing this with irb in the console and when I exit and try again, the cookie is gone.

How do I save it for a few days/weeks? I'm using pure ruby without Rails or anything.

Thanks so much.

A: 

Ruby Mechanize has a cookie jar and cookie class. It's fairly straight forward, and seems independent from the rest of the library. You construct and add cookies, specifying the URL, and later you use the cookies method to check which cookies apply to a given URL. You can serialize the jar with save_as and deserialize with load.

Matthew Flaschen