1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Any way to detect referring link

Discussion in 'PHP' started by david_sakh, Jan 7, 2005.

  1. #1
    Is there any way to detect if a user acesses a page from an internal link in my site?
    SEMrush
    I was thinking about doing something in php only if a user has already visited a least one page on my site. Is there any reasonably simple way this could be done?
     
    david_sakh, Jan 7, 2005 IP
    SEMrush
  2. phrozen_ra

    phrozen_ra Peon

    Messages:
    147
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    yeah... at the beginning of every page you put this

    session_start();
    if ($visited) echo 'visitor coming from within the site'; else
    {
    $visited = true;
    session_register('visited');
    echo 'visitor came from outside the site';
    }

    this will display on every page if the visitor came from within the site or from outside.... but with a few tweaks you'll get what you want
     
    phrozen_ra, Jan 7, 2005 IP
  3. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    64
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Besides session variables (see the previous post), you can also look at the Referer header. If its beginning matches the Host header, an internal link was clicked.

    Keep in mind that Referer may be easily forged - don't use this mechanism for anything important.

    J.D.
     
    J.D., Jan 8, 2005 IP
  4. david_sakh

    david_sakh Peon

    Messages:
    1,225
    Likes Received:
    29
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Many thanks, phrozen.

    I wasn't going to, but I'll be sure to keep that in mind.
     
    david_sakh, Jan 8, 2005 IP