"HTTP is a sessionless protocol". What that means is that there is basically no way for the server to determine absolutely "where the user came from", because a request for a page is a request for a page, and that's all. However, silly pages can offer javascript to "press the Back button", which is generally not useful, since the user already has a Back button. Sensible pages may offer a way back to somewhere *specific* to the website.
For example, if you go to my puzzle shop - e.g.
http://imaginatorium.org/shop/calendar.htm and click a puzzle or two "Add to basket" , then go to the checkout, you'll see that there's a "Continue shopping" link. Clicking it takes you back to the page (Calendars) you were looking at. You can wander around the checkout, with the View basket link for example, but "Continue shopping" still goes back to the puzzle page. If you go directly to a checkout page - for example
http://imaginatorium.org/shop/ship.php?des...6+E13238+E13237...then "Continue shopping" just takes you back to the Shop Front page.
Is this what you mean? If so, since mine just passes GET parameters around, it's transparent what's going on, and well, you could just do the same. (Of course, if you were hoping for "A code" to do this, there isn't one.)