Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Getting the url of referring page

by ichimunki (Priest)
on Jul 19, 2002 at 22:35 UTC ( #183484=note: print w/ replies, xml ) Need Help??


in reply to Getting the url of referring page

Is there a way? Yes.

It looks a bit like:

#!/usr/bin/perl -w use strict; use CGI; my $C = CGI->new; if($C->referer eq 'some URL'){ process_page(); } else{ bounce_page(); }
Suggested reading: perldoc CGI

update: I should've mentioned what dws mentions below, that referer is not always present or accurate (although one can make a case for why browsers should *not* strip/alter this header). Your other solution is to generate a session ID or form key on the originating page (as a hidden field) that must be submitted along with the form or used as part of the URL. But that will only work if you are using forms, not just plain links. You might be able to get it to work with some JavaScript trickery, but to my way of thinking that's worse than simply denying access to people who munge referer headers.


Comment on Re: Getting the url of referring page
Select or Download Code
Re: Re: Getting the url of referring page
by Theseus (Pilgrim) on Jul 20, 2002 at 00:39 UTC
    This could be done rather simply with a cookie, as well. Then you don't have to worry about whether or not your user is navigating through forms or links. Of course, if they have cookies turnes off, you're outta gas.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://183484]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (15)
As of 2014-07-30 13:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (232 votes), past polls