Print Page | Close Window

ServerVariables("HTTP_REFERER")

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=1019
Printed Date: 29 March 2026 at 5:17am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ServerVariables("HTTP_REFERER")
Posted By: chris@artwebs.c
Subject: ServerVariables("HTTP_REFERER")
Date Posted: 14 March 2003 at 3:11pm

What is wrong with this code?

Session ("CC_referingURL")=request.ServerVariables("HTTP_REFERER")
if (Session ("CC_referingURL")<>"") then Session ("CC_referingURL")="None" End if

Why does it always return "None" in the page and not the ("HTTP_REFERER")

 




Replies:
Posted By: michael
Date Posted: 14 March 2003 at 3:20pm
Because probably noone is linking to your site (from an other domain that is)


Posted By: Nigelo
Date Posted: 14 March 2003 at 4:40pm
Originally posted by chris@artwebs.c chris@artwebs.c wrote:

What is wrong with this code?

Session ("CC_referingURL")=request.ServerVariables("HTTP_REFERER")
if (Session ("CC_referingURL")<>"") then Session ("CC_referingURL")="None" End if

Why does it always return "None" in the page and not the ("HTTP_REFERER")

Maybe I'm missing the point but why not recode as follows:

Session ("CC_referingURL")=request.ServerVariables("HTTP_REFERER")
if (Session ("CC_referingURL")="") then
 Session ("CC_referingURL")="None"
End if

Your example resets Session(CC..) to "None" whenever the Referrer is anything other than a ZLS which is the reverse of what you intended.

Hope this helps
Nigel   



Posted By: chris@artwebs.c
Date Posted: 15 March 2003 at 12:20pm

Thanks Nigelo

I have changed the code and it still does not work

I have links to this site, but always get "None" , do all servers support request.ServerVariables("HTTP_REFERER")?

Can this be switched off on the server?



Posted By: michael
Date Posted: 15 March 2003 at 12:38pm
I don't think you can deny a single server variable and it might be that it is only supported on win2k, don't know.


Posted By: chris@artwebs.c
Date Posted: 15 March 2003 at 12:50pm

Ok

So, any ideas why it don't work?

 



Posted By: Nigelo
Date Posted: 15 March 2003 at 6:56pm

Have taken another look and think that retrieving the referer should be seperated from your Database write as follows:

strRef=request.ServerVariables("HTTP_REFERER")
If strRef="") then strRef="None"

'write strRef to Database or whatever



-------------
Hope this helps
Nigel


Posted By: chris@artwebs.c
Date Posted: 16 March 2003 at 3:44am

Hi Nigelo,

Still no joy:

Dim strRef
strRef=request.ServerVariables("HTTP_REFERER")
If (strRef="") then strRef="None"
Session ("CC_referingURL")=strRef

Always return "None" even if I write strRef to the page or database.

I have links on other sites, other domains and even in Google.


Any other ideas?

This should work....just can't see why it don't.



Posted By: Bunce
Date Posted: 16 March 2003 at 4:03am
What do these return if you put them at the end of your code:

response.write request.servervariables("HTTP_REFERER")
response.write strREF
response.write Session("CC_referingURL")

-------------
There have been many, many posts made throughout the world...
This was one of them.


Posted By: chris@artwebs.c
Date Posted: 16 March 2003 at 8:34am

Hi Bunce

This is the result writen to the page the ("HTTP_REFERER") is blank?

HTTP_REFERER=  

strRef= None  

CC_referingURL= None 



Posted By: Bunce
Date Posted: 16 March 2003 at 7:11pm

Then I think its probably being blocked somewhere.

Referer is not very reliable and can be blocked by Server / ISP and be spoofed by the client.

If you do a quick search on google for Blank HTTP_Referer you'll find a number of links describing the issue.

Cheers,
Andrew



-------------
There have been many, many posts made throughout the world...
This was one of them.


Posted By: chris@artwebs.c
Date Posted: 18 March 2003 at 2:50pm

Thanks Bunce

Must be being blocked somewhere.

Will use a bit of java script instead to get the referer

Thanks for your help



Posted By: Bunce
Date Posted: 18 March 2003 at 3:55pm

You can try, however if its getting blocked then I doubt it will matter what language you try as its not available...

Cheers,
Andrew



-------------
There have been many, many posts made throughout the world...
This was one of them.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net