Web Analytics Made Easy -
StatCounter reliable way to detect referring page? - CodingForum


No announcement yet.

reliable way to detect referring page?

  • Filter
  • Time
  • Show
Clear All
new posts

  • reliable way to detect referring page?

    Is there a reliable way in php to detect the referring page.
    eg I have a form that I submit to a generic processing page - now is there a reliable way to detect the page(including querystring) they came from and send them back there?

  • #2
    sessions , on the page that displays the form , set a session variable...
    PHP Code:
    ['form_timestamp'] = mktime() ; 
    $_SESSION['form_return_url'] = 'http://www.blah.com/forms/form.php' ;
    $_SESSION['form_data'] = $_SERVER['QUERY_STRING'] ; 
    ...or some variation of the above , they will be available at the form processing page for munging & will give you enough data to decide if the form is new enough to bother with where it came from and any GET variables you need to redisplay the form, it should also give you confidence that the form actually came from your own server though not with certainty , create a password/identifier to pass around to be more sure of that.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


    • #3
      there is $_SERVER['HTTP_REFERER'] but no that is not very reliable. i suggest you pass a variable to the form processor (via GET, hidden POST or session) that tells the form form processor where to go after finishing.


      • #4
        Use the session method (or similar if db driven) is probably your best route. Both the GET and POST methods, though usable, are easily spoofable. The session method, though not foolproof either, is your best bet as it would be tough to stab at an unknown sessionid to hijack.
        PHP Code:
        header('HTTP/1.1 420 Enhance Your Calm'); 
        Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)