Can I Detect Visiting URL?

They have: 12 posts

Joined: Jun 2007

Using PHP is it possible to detect a visiting URL? I would like to add some code to my index.php script that could tell me where my visitiors are coming from (which URLs). Can this information be captured somehow with PHP?

Thanks...

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

Yup, it's in the $_SESSION['HTTP_REFERER'] variable.

They have: 12 posts

Joined: Jun 2007

I get a blank when I use this code snippet on my home page:

$ref = $_SESSION['HTTP_REFERER'];
print $ref;

He has: 1,380 posts

Joined: Feb 2002

not $_SESSION['HTTP_REFERER'], but rather:

<?php
$_SERVER
['HTTP_REFERER'];
?>

That will do the trick.

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

Woops. That's what I meant. Cool

He has: 1,380 posts

Joined: Feb 2002

No worries... hahah

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.