I’m looking for a way to add parameters to a cgi object and then
redirect the user to another cgi script off site.
require “cgi”
cgi = CGI.new
cgi.params[‘new_param’] = “new_value”
…
cgi.header(“status” => “302”,
“location” => “offsite_script.cgi”)
I can add parameters no problem as above, but the offsite script isn’t
receiving the added parameters. Is this because the redirect is
happening before the parameters are being added? Is there another way to
do this?
Thanks,
Dave
OK, so the above isn’t working because 302 is being return to the
client, which is re-sending the original params to the redirect location
(offsite_script.cgi)
I’ve played around with Net:HTTP this seems to be sending the data but
the user is oblivious to this. Is there a way to add params to the cgi
hash and forward the user on? Essentially I’m looking for this script
that adds params to be transparent to the user.
You should use cookies (maybe with cgi session), or add the paramenters
to the
url, for example:
puts cgi.header(‘status’ => ‘REDIRECT’,
‘location’ => ‘offsite_script.cgi?new_param=new_value’)
http://www.ruby-doc.org/core/classes/CGI/Session.html
http://www.ruby-doc.org/core/classes/CGI/Cookie.html
Good ideas, but the offside script needs the post method and doesn’t
accept parameters passed through the URL. I also don’t have the ability
to change the offsite script so cookies are out as well.
Is there no way to forward a user on? This is easy enough to do on the
client side with Javascript, but if a user has scripting turned off none
of it will work.
Dave
Martin B. wrote:
You should use cookies (maybe with cgi session), or add the paramenters
to the
url, for example:
puts cgi.header(‘status’ => ‘REDIRECT’,
‘location’ => ‘offsite_script.cgi?new_param=new_value’)
http://www.ruby-doc.org/core/classes/CGI/Session.html
http://www.ruby-doc.org/core/classes/CGI/Cookie.html