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

I'm using HTTP_REFERER to get the users last referred web page. By this method they are deferred a different way depending on where they came from. This works great in Netscape 7,6,4, but I can't get it at all to work on Internet Explorer 6 and I've lowered all the security setting on IE 6 options. It bascially returns NULL when a link is clicked on, which it's only suppose to return NULL if they type the url in or go from a bookmark. Does this environment variable have a probelm in IE 6. My code is just this $refer = $ENV{'HTTP_REFERER'}; if ($refer eq "http://www.isu.edu") { #do process }else{ #do something else }

Replies are listed 'Best First'.
Re: HTTP_REFERER Problem
by dga (Hermit) on Mar 27, 2003 at 18:17 UTC

    This is information supplied at the whim of the browser. There is no guarantee that the referer is even valid since the browser can set it to anything it wants to.

    Practically, this means you should have a reasonable default case in your script to handle the condition where referer isn't set or isn't one of the locations you want to act on.

    Keep in mind of course that the referer could be set to one of your checked locations even though the browser has never even been there.

    Also consider that the referer might be 'http://www.isu.edu/' instead of 'http://www.isu.edu' which both are probably the same place.

    my $referer=$ENV{HTTP_REFERER}; if($referer eq 'place1') { ... } elsif($referer eq 'place2') { ... } else #not set or not cared about { #do default actions here }
Re: HTTP_REFERER Problem
by iguanodon (Priest) on Mar 27, 2003 at 19:35 UTC
    To add to what dqa said, note that some people configure their proxy servers to not provide HTTP_REFERER for security reasons, so it's pretty unreliable in general use.

Re: HTTP_REFERER Problem
by tachyon (Chancellor) on Mar 27, 2003 at 23:54 UTC

    As well as using HTTP_REFERRER if your main issue is intra-site (ie you want to know which page on your site they have come from) then all you need to do is set a cookie called last page for every page the user visits. You can then access this as required. You can configure Apache to do this for you using mod_usertrack and then the CookieTracking directive.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: HTTP_REFERER Problem
by koryw (Novice) on Mar 29, 2003 at 08:51 UTC
    Thank you for all your responses I appreciate it.