SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Pragmatic Programmer halfasleeps's Avatar
    Join Date
    Feb 2006
    Location
    Altoona, PA. USA
    Posts
    1,945
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_SERVER['HTTP_REFERER'] not working in conjunction with 301 re-route

    I have this in place on every page to track where users found us from:

    PHP Code:
    if(!isset($_SESSION['referal'])){
        
    $web_referal $_SERVER['HTTP_REFERER']; 
        
    $web_referal parse_url($web_referal);
        if(
    $web_referal['host'] != 'www.kranichs.com'){
            
    $_SESSION['referal'] = $web_referal['scheme'].'://'.$web_referal['host'].$web_referal['path'].'?'.$web_referal['query'];
        }
        if(
    $_GET['tracking']){
            
    $_SESSION['tracking'] = $_GET['tracking'];
        }else{
            
    $_SESSION['tracking'] = 'none';
        }

    it works except if the first page the user hits on our site is a 301-re-route it gets lost

    for instance:
    if they go from google strait to page A and page A has a 301-re-route to page B....then the referal information gets lost.

    I believe because page A is refered from google but never gets a change to run the code and gets directly re-routed to page B and then when page B runs the code it wasnt refered from google it was adjusted in the server...

    Does anyone know how I can fix this?

    THANKS!
    Altoona Design
    Freelance Flex developer for hire.
    ActionScript Programmer with 8 Years Experience.

  2. #2
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you shouldn't rely on HTTP_REFERER I can disable referrer logging in my browser, try QUERY_STRING
    my mobile portal
    ghiris.ro


Bookmarks

Posting Permissions

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