alternative to HTTP_REFERER?

Discussion in 'PHP' started by greatlogix, Nov 6, 2008.

  1. #1
    Hello; I just wrote a script that needs to know what the referring page is but "$_SERVER['HTTP_REFERER']" does not seem to be working. Is there a way around this?
     
    greatlogix, Nov 6, 2008 IP
  2. norfstar

    norfstar Peon

    Messages:
    1,154
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Some people's browsers, and most robots, are set not to disclose the HTTP referrer, which might be what is happening to you. As far as I know there is not an alternative.
     
    norfstar, Nov 6, 2008 IP
  3. keyaa

    keyaa Peon

    Messages:
    137
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If the referring page is one of your own, you could use one-time tokens (also useful to prevent CSRF) or cookies, other than that - $_SERVER['HTTP_REFERER'] needs PHP > 4.1, so if your version is outdated, try $HTTP_SERVER_VARS['HTTP_REFERER']
     
    keyaa, Nov 6, 2008 IP
  4. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #4
    Referring page is from another site and i don't have control of referring site. I am using PHP5.
     
    greatlogix, Nov 6, 2008 IP
  5. keyaa

    keyaa Peon

    Messages:
    137
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    $_SERVER['HTTP_REFERER'] should work then. Are you sure the referer is being supplied by the browser you tested with?
     
    keyaa, Nov 6, 2008 IP
  6. nickstan

    nickstan Peon

    Messages:
    781
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #6
    nah most modern browser (IE 7 / FF / Opera) allows user to block any server referrer request to protect user privacy :)
     
    nickstan, Nov 6, 2008 IP