Mechanize Ruby: Print Cookies

632 Views Asked by At

When I do agent.get(URL) I get blank results while when I access the URL directly I can see the results. Is it because some cookies are passed to the result page? Can you please help me to print cookies before agent.get(URL) so that I will know what is being passed?

1

There are 1 best solutions below

0
Mohamed Rafiq P On BEST ANSWER

I could solve this by adding the cookies before submitting the form.

agent = Mechanize.new
cookie = Mechanize::Cookie.new(name: '#{name}', value: '#{value}', domain: '#{domain}', path: '/')
agent.cookie_jar.add(cookie)