I need to hook into whenever a user moves from one page to another. I need to know where they are coming from and where they are going. My scenario is that anytime that a user heads to a certain section of the site (search) it modifies the path to add a variable. But I only want to to do so when they are coming from outside that section of the site.
I have been looking at hook_url_inbound_alter() which gets me in when a user is about to move to another page, and gives me where they are going, but not where they came from. Any suggestions?