sredhar8 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I tried redirecting from one cgi script to another ...lets say from (script1 --> script2). I tried to retrieve the HTTP_REFERER argument in script2 and found there was no value in it. I am using cgi.pm & perl 5.8. I also tried the referer() function to the same effect. However, when I redirect from (html page --> script2), the referer argument in script2 rightly reflects the url of the html page. Is there someway I could get the referer argument while redirecting from (script1 --> script2). Thanks, sredhar
  • Comment on referer argument while rediecting from cgi scripts

Replies are listed 'Best First'.
•Re: referer argument while rediecting from cgi scripts
by merlyn (Sage) on Jul 22, 2003 at 00:18 UTC
    Why does it matter? REFERER is only an interesting value for logging and doing back-of-the-envelope flow-analysis on your overall website.

    You surely can't be using it for authentication or authorization, because it's trivial to forge, and get stripped by security firewalls, and also comes back wrong or differently on different browsers, as you've noticed.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

Re: referer argument while rediecting from cgi scripts
by waswas-fng (Curate) on Jul 22, 2003 at 04:25 UTC
    As has been stated before many times HTTP_REFERER is a silly toy that can't be trusted more than anything else that is submitted on a form. Any time you feel the need to trust the HTTP_REFERER's value you need to change your approch. It should not be used for auth, site flow (unles your output of site flow is considered as untrustworthy as HTTP_REFERER itself) or anything else you need to trust.

    -Waswas
Re: referer argument while rediecting from cgi scripts
by bobn (Chaplain) on Jul 22, 2003 at 00:43 UTC

    It's completely a matter of what the browser decides to do, because it's the browser that sends the referer header. My experience is that Mozilla bowser doesn't change the referer ehader based on redirects, though that research was limited to (I think) Mozilla.

    --Bob Niederman, http://bob-n.com