Use some session mechanism, send cookies to the user, and store the data on the server per session in a database.
When the user comes from redirected page you have the session cookie and you can easily get the necessary variables and other data needed (of course, all pages in 'Location' must be under the same domain for getting cookies properly).
Update: CGI::Session might be good place to start.