detect last url visited

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
speedy33417
Forum Contributor
Posts: 128
Joined: Sun Jul 23, 2006 1:14 pm

detect last url visited

Post by speedy33417 »

How do I detect where the user is coming to my page?

I'd like to create a custom statistics page for myself, to track traffic on my site. I have no problem once the user is on my site and moving between pages, but I'm not sure how to grab that info if they arrive from an outside page.

Thanks.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

The best way is to have your pages interact with the database, as in each page request is recorded by the requested page. Tied in with their session_id you can track their movements.

Table footprints

Code: Select all

ID   PAGE   SESSION_ID
1    4      bleh
2    6      bleh
3    3      bleh2
This is best accomplished with a front controller, where all the actions are routed through a single request. This way, you can intercept the requested page, make notes of it (time, session_id, page request) and then load the page
The Ninja Space Goat wrote:$_SERVER['HTTP_REFERER']
== unreliable

HTTP_REFERER is an optional value, of which the browser can easily disable.


EDIT| sorry I didn't properly read your question, might as well ignore me :D
Last edited by John Cartwright on Tue Oct 31, 2006 4:30 pm, edited 1 time in total.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Jcart wrote:
The Ninja Space Goat wrote:$_SERVER['HTTP_REFERER']
== unreliable
HTTP_REFERER is an optional value, of which the browser can easily disable.
I know this... but isn't it the only way to get the referer? I know you can track where they are going within YOUR site... but what about where they came from?
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

I think that's it...
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Here is a nice hack that tries to figure out where you've been: http://jeremiahgrossman.blogspot.com/20 ... -been.html.
Post Reply