From: Alex Ciarlillo Date: 2006-11-30T05:09:51+09:00 Subject: Re: how to input info in fields on a HTTP page? Okay I got some code working to login to the site Im interested in, but this led me to a new question. How can I keep this session alive once logged in? After login I need to follow a link on the page in order to start posting data to get my reports but I believe the connection is closing as soon as it posts the login data. I think this requires a stand alone http object which then processes each request but I havent had any luck getting this code to work like that. I was also thinking that I may need to make further requests inside the start block but that would depend on the case of 'res' so I didnt think that was the right track. Here is the code I have now, any input would be really appreciated. require 'net/http' require 'uri' url = URI.parse('http://xxx.xxx.xxx.xxx/servlet/PortalLogIn/') req = Net::HTTP::Post.new(url.path) req.set_form_data( {"command" => "login", "cpny" => "xxx", "usr" => "xxx", "pwd" => "xxx" } ) res = Net::HTTP.new(url.host).start { |http| http.request(req) } case res when Net::HTTPSuccess, Net::HTTPRedirection puts "OKAY it worked!" puts res.body else res.error! end -- Posted via http://www.ruby-forum.com/.