Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here




Where can I find information on how the 'referrer' is set?  

Specifically, I want to check the referrer to ensure that the page is being accessed from the proper site (also, I do different things if it came from outside the site versus if the user was already in the site and just coming back to the main page).

If a user comes in the 'normal' way (from 'page1.asp') it works fine.  However, if the user is redirected from 'page2.asp' to 'page1.asp' to my page, the referrer appears to be blank! Not even a hint of a URL!  Does this make sense?  Is there any other way I can tell where the page is being called from?  

RE: Referrer

One of the best sites I've found is here:


That is the whole collection of the Request.Servervariables object, which includes a description of Request.Servervariables("HTTP_REFERER").

What I've found is that when I'm in a situation where I care about the referer I usually assign a session variable. An example would be that I had two main pages a user would be using the same service from, either "active" or "closed." Right on the active and closed pages respectively I would set session("referer") to the current URL. That way after a number of forms had been filled out and lots of pages used and data collected, I could redirect to the session("referer"), which was set to one of the two important pages that I needed to return the user to.

Hope this helps!

RE: Referrer

Using HTTP_REFERER will show a blank for redirects:

Quote (from w3Schools):

Returns a string containing the URL of the page that referred the request to the current page using an <a> tag. If the page is redirected, HTTP_REFERER is empty
I use a bit of JavaScript to check for the referrer:


if (document.referrer != "http://myserver/LBRREL/logon/my_logonform.asp"
 window.alert("Invalid Entry Point - Access Denied")

Probably better ways, but this seems to work ok..

To Paraphrase:"The Help you get is proportional to the Help you give.."

RE: Referrer

The value is not set by the server, it is set by the web browser.  It is also not required by the HTTP spec so not all browser will set it under the same circumstances.

Unless you are developing for an Intranet where you can be sure that all users have the same version of the same browser, I wouldnt use it for anything more important than fancy homebrew usage logs.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close