Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I print out the cookies that Mechanized has stored?

Tags:

ruby

mechanize

I'm using mechanize to login into a website and then retrieve a page. I'm running into some problems and I suspect this is due to some values in the cookies. When Mechanize logs into a website I assume it stores the cookies.

How do I print out all the data stored in the cookies by Mechanize?

like image 494
Janak Avatar asked Apr 02 '10 11:04

Janak


1 Answers

The agent has a cookies methods.

agent = Mechanize.new
page = agent.get("http://www.google.com/")
agent.cookies
agent.cookies.to_s

The cookies return is a Mechanize::Cookies object

like image 107
shingara Avatar answered Oct 23 '22 09:10

shingara