There are several ways you might do this.
add 'template' php to your pages with hidden inputs so every click tells the next page who is accessing.
Include a login and/or use php's built in session handling.
Use cookies
Sesion handling is the best.
If you need to track users between sessions then team this up with cookies or use a login against a registered user base.
Cheers,
Cris