justuptime.com - monitor your servers & websites

Can I Detect Visiting URL?

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

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
ModeratorSponsor

He has: 855 posts

Joined: Sep 2006

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

PHP Starter - PHP Tips & Tools From Starters to Experts

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;

brady.k's picture

He has: 1,383 posts

Joined: Feb 2002

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

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

That will do the trick.

Kyle Brady, President, Intuitive Industries LLC.
http://www.int-ind.com
[EMAIL=brady.k@gmail.com]brady.k@gmail.com[/EMAIL] - [EMAIL=brady.kyle@int-ind.com]brady.kyle@int-ind.com[/EMAIL]

pr0gr4mm3r's picture
ModeratorSponsor

He has: 855 posts

Joined: Sep 2006

Woops. That's what I meant. Cool

PHP Starter - PHP Tips & Tools From Starters to Experts

brady.k's picture

He has: 1,383 posts

Joined: Feb 2002

No worries... hahah