Can I Detect Visiting URL?
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 posted this at 17:56 — 6th July 2007.
He has: 1,502 posts
Joined: Sep 2006
Yup, it's in the $_SESSION['HTTP_REFERER'] variable.
frank727 posted this at 18:26 — 6th July 2007.
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;
kb posted this at 18:29 — 6th July 2007.
He has: 1,380 posts
Joined: Feb 2002
not $_SESSION['HTTP_REFERER'], but rather:
<?php
$_SERVER['HTTP_REFERER'];
?>
That will do the trick.
pr0gr4mm3r posted this at 18:31 — 6th July 2007.
He has: 1,502 posts
Joined: Sep 2006
Woops. That's what I meant.
kb posted this at 18:37 — 6th July 2007.
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.