Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    BHL
    BHL is offline
    New to the CF scene
    Join Date
    Jan 2003
    Location
    NY
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Referral URL not getting set

    Hello all--

    I am building a script that is going to track information on how the user got to my site. One of the most important pieces of information that I need to capture is the referral URL. From what I have read, the _SERVER[HTTP_REFERER] is supposed to be what I am looking for but it is always empty. Does anyone have any ideas on why? Any insight would be appreciated. Thanks

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Assuming you spelled it correctly in your actual coding it would be :

    _SERVER[HTTP_REFERRER] vs. _SERVER[HTTP_REFERER]

    Secondly I wouldn't rely on it. The referrer information is coming from the users web browser. It will only come if they click on a link. If its a bookmark, or they type in the address, or select it from the dropdown history then referrer will be blank. On top of that not all browsers actually send the referrer information or even send it correctly. And some browsers allow people to change that information.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    New Coder
    Join Date
    Dec 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Spookster
    Assuming you spelled it correctly in your actual coding it would be :

    _SERVER[HTTP_REFERRER] vs. _SERVER[HTTP_REFERER]
    That's assuming there wasn't a typo in the php engine

    http://www.php.net/manual/en/reserved.variables.php

    You can reference it via $_SERVER['HTTP_REFERER']

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Originally posted by redstormaudio
    That's assuming there wasn't a typo in the php engine

    Oh my gosh. lol. I hadn't even noticed that before.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    As far as I understand, the sending of "HTTP_REFERER" in the request headers is a browser and ISP/proxy thing. Some do, some don't.

    That's why most .hta (mod_rewrite and the like) normally have a condition that sniffs for an empty referer string
    {HTTP_+REFERER} !^$ (referer not empty)
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ... it's REFERER because most languages are in American, not English (hence "color=red" etc) ...

  • #7
    New Coder
    Join Date
    Dec 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    English or American, it's still a typo.

  • #8
    BHL
    BHL is offline
    New to the CF scene
    Join Date
    Jan 2003
    Location
    NY
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ok, if this is an unreliable way to get this peice of information, does anyone know of a better way?

  • #9
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You won't find anything better than that...

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What you could do is set a cookie or session identifier on page A, and verify it on page B

  • #11
    BHL
    BHL is offline
    New to the CF scene
    Join Date
    Jan 2003
    Location
    NY
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am more interested in the information coming from the search engines. The query string with the search terms and the actual search engine the user used to find the site is what I need.

  • #12
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    As mentioned, you can only use the request headers that are sent to access your page. If certain browseing setups are not sending the headers you want, you cannot make the information appear. Just like you cannot sniff Opera through $_SERVER['USER_AGENT'] if someone is spoofing mozilla.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #13
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <slightly_off_topic>

    Originally posted by Ökii
    Just like you cannot sniff Opera through $_SERVER['USER_AGENT'] if someone is spoofing mozilla.
    yes you can .. even in spoof modes, the word "Opera" always appears in its UA string ...

    </slightly_off_topic>

  • #14
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    does it, blimey not very good spoofing that.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •