Checking/Forcing Referrer Pages - 6/7/2000 16:19:00
Originally posted by Mike O at http://www.frontpagewebmaster.com/ubb/Forum1/HTML/001711.html quote:
The Asp script is :<% Response.Buffer = True 'checks previous page is valid sPg = Request.ServerVariables("HTTP_REFERER") If (Instr(sPg,"URLofsendingpage") = 0) and _ (Instr(sPg, "URLofthispage") = 0) then Response.Clear Response.Redirect("URLoferrorpage") End If %> Place this above the <HEAD> tag. "URLofthispage" is required in case Refresh is clicked. "URL..." can be the complete URL or any part of it. If developing the page using PWS then publishing to another server then the full URL of the pages may change. This has to be corrected in the script at the time of publishing. If the page can be called by more than one page then add another "and _" line to the above script. If the test fails then Response.Redirect("URLoferrorpage") sends the visitor to an error screen. Otherwise the current page is displayed. Hope this helps.
This code can be used to check that a visitor has reached a page through a secure server, for example, or by completing a form, or for invalidating bookmarks, or any number of useful ways. The original post also contains a link to a tutorial on building a cookie that will perform the same task. Cookies could be useful for controlling repeat visitors. ------------------ You! Off my planet! ------------------- Work, work, work: http://www.appercept.co.uk Out of Office Hours: http://www.darlingbri.co.uk
|