title: PHP persistent referer
body: <p>In my app, I have a few forms that can be accessed from different urls in the app. Each form has a cancel button, that should return the user from the url that they previously came from.</p>
  
  <p>So, this is pretty easy to achieve with $_SERVER['HTTP_REFERER'].</p>
  
  <p>The problem comes into being when the user submits the form, and it fails validation. So, at that point, the $_SERVER['HTTP_REFERER'] is the form itself. Obviously, the cancel button wont work properly then, since the original referer has now been 'lost'.</p>
  
  <p>What is the best way around this? Should I be storing the original referer in the session, or perhaps via a hidden form field? Or perhaps there is another more elegant method?</p>