Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

Join Tek-Tips
*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.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

apple17 (Programmer) (OP)
8 Aug 06 15:28
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?  
Abraxus (Programmer)
8 Aug 06 15:40
One of the best sites I've found is here:

http://www.w3schools.com/asp/coll_servervariables.asp

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!
Turkbear (TechnicalUser)
8 Aug 06 16:16
Hi,
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:

CODE

<SCRIPT LANGUAGE="JavaScript">
if (document.referrer != "http://myserver/LBRREL/logon/my_logonform.asp"
{
 window.alert("Invalid Entry Point - Access Denied")
 location.href="Http://myserver/LBRREL/logon/my_logonform.asp"
)
 
</SCRIPT>

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



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

Sheco (Programmer)
9 Aug 06 0:29
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.

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