Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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.

Replies are listed 'Best First'.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://183484]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2017-12-17 20:33 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (466 votes). Check out past polls.