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

Hi, I have a problem from a cgi I pop-up a window in that window I want the url of the referer page. Can anyone help please. THX...

Replies are listed 'Best First'.
Re: can't get $ENV{HTTP_REFERER}
by zby (Vicar) on Mar 24, 2003 at 14:24 UTC
    If you used Cgi.pm you would have that nice referer method on the $request object.

    Ofcourse the Referer HTTP header is not obligatory for the browser to set, and even in some circumstances it is should not be set:

    Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure protocol.

    from rfc2616.

Re: can't get $ENV{HTTP_REFERER}
by Chady (Priest) on Mar 24, 2003 at 14:11 UTC

    IIRC, HTTP_REFERER can be spoofed and sometimes it doesn't get set, therefore is unreliable.

    anyway, did you use $ENV{HTTP_REFERER} and it didn't work? where's the code?


    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

    Chady | http://chady.net/
Re: getting referer from a popup window
by benn (Vicar) on Mar 24, 2003 at 14:18 UTC
    It depends on how you opened the window - if you used 'target=_new' then HTTP_REFERER should be OK, but if you used a Javascript 'window.open', then I think the only way is by using 'window.opener.location'. Good luck.
      Thank you for reply... I used javascript but window.opener.location causes error on page
        window.opener.location.href maybe?