Solved

HTTP_REFERER

Posted on 2007-03-29
10
466 Views
Last Modified: 2012-03-15
I want to log the Request.ServerVariables("HTTP_REFERER") when the 1st time a user enters any page on my root domain.  They could enter the site from say a search engine and land on page 2 of my site.  Then they may go to page 3 from there.  When the user land on page 2 I want to log the other dmain address they came from.  How do I do this?
0
Comment
Question by:jeffreytp
  • 4
  • 2
10 Comments
 
LVL 22

Expert Comment

by:WMIF
ID: 18818088
you can do this a couple ways.  it depends on your server and if you have access to a file called global.asa.  if you dont have access, its real easy to just track this with a session variable.  make a file that you would include on all of your pages.  this will check for a session variable and record your referer value if that session variable doesnt exist.  if it does, just go back to the first page.

include file:
<%
if not session("gotrefer") = "true" then
  'log http_referer
end if
%>

all other files:
<!--#include file="aboveinclude.asp"-->
<%
'other asp code...
0
 
LVL 22

Expert Comment

by:WMIF
ID: 18818093
oops, forgot one line:


include file:
<%
if not session("gotrefer") = "true" then
  'log http_referer
  session("gotrefer") = "true"
end if
%>

all other files:
<!--#include file="aboveinclude.asp"-->
<%
'other asp code...
0
 

Author Comment

by:jeffreytp
ID: 18818273
Thank you for your input WMIF  I played around with the asp code you provided and this is the code that does what I intended it to do, maybe you didn't quite understand what I was saying:

if not session("referer") > "" then
  'log http_referer
  session("referer") = Request.ServerVariables("HTTP_REFERER")
end if
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 22

Expert Comment

by:WMIF
ID: 18818413
that will definately store the referer information into a session variable, but i figured that you wanted to store this information into a database or file of somesort.  that is what i intended to replace the comment "log http_referer".  sorry i did not explain that better.  do you only want to store this into a session variable?
0
 

Author Comment

by:jeffreytp
ID: 18818434
for now, and then I can take the session and place that into a DB.
0
 
LVL 22

Accepted Solution

by:
WMIF earned 50 total points
ID: 18819435
i would place the code in the include file to store the value into the db.
0
 
LVL 14

Expert Comment

by:B_Dorsey
ID: 18821041
Just a heads up "Request.ServerVariables("HTTP_REFERER")" is not reliable as most antivirus packages like NORTON block it from showing up
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
format nvarchar field as mm/dd/yyyy 4 80
Display first 3 lines of text from database field, vbscript asp 4 60
Select case on click 3 21
Html Table looping 4 26
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question