Best solution for getting referral information in PHP
<p>I am currently redoing some link structuring on a website. In the past we have used specific php files on the last step to direct the user to the proper place.</p>

<p>Example:</p>

<pre><code>www.example.com/action/go-to-blue.php
</code></pre>

<p>or</p>

<pre><code>www.example.com/action/short/go-to-red.php

www.example.com/action/tall/go-to-red.php
</code></pre>

<p>We are now restructuring to eliminate the <code>/short/</code> or <code>/tall/</code> directory. What this means is now <code>go-to-blue.php</code> will be doing some extra processing to make sure it sends the visitor to the proper place.</p>

<p>The static method of the past was quite effective, because, well, if they left from that page we knew we had it right. Now since we are 301 redirecting <code>action/short/go-to-red.php</code>
to just <code>action/go-to-red.php</code> it is quite important on <code>go-to-red.php</code> that we realize a user may have been redirected from <code>/short/</code> or <code>/tall/</code>.</p>

<p>So right now I am using HTTP_REFERRER and of course in my testing that works fine, but after a lot of reading it is clear that this is not a solid solution, so I was starting to brainstorm on other ways to check and make sure we get the proper referral information.</p>

<p>If we could check HTTP_REFERRER plus some other test, I would feel confident we have a pretty good system in place to send the visitor to the right place.</p>

<p>Some questions/comments:</p>

<ol>
<li>Could I use a session variable or a cookie to accomplish this goal?</li>
<li>If so, would that be maintained through the 301 redirect? I don't see why it wouldn't be..</li>
<li>Passing the url in the url is not an option in this case.</li>
</ol>
