| Purpose: Capture referring page information, trim the referring informaion and send the user to a different page if not sent directly from the page you want Code: CGI, CFML, HTML First, to get the referring page information, reference the CGI variable, CGI.HHTP_REFERER. For the sake of this example, we just want to see if the referer was from somewhere in the curiouscat.com/code directory so we just care about the first 30 characters (you can choose however many characters you wish, or just use the CGI.HTTP_REFERER variable directly). Using the Cold Fusion LEFT string function strips the extra characters providing the number of characters you choose:
Then you could use CFLOCATION to send them to a page you specify, if the referer doesn't match the correct directory: This is just meant to be a simple example. Often using an application framework and having users sign in is required to achieve what you want; in some simple instances this example may provide some help. |
More CGI variable information: |