jQuery - Previous URL
For a clients website I needed to figure out a way to save the previous URL that the visitor came from. This was incase of any errors that occurred, I could just send them back.
<script type="text/javascript">
$(document).ready(function() {
var $referrer = document.referrer;
});>
</script>
You can then include the variable $Referrer into anywhere you want -
Go Back Link:
<a href="<?php $referrer ?>">Click here to go back.</a>
Be careful though as many browsers can disable the referrers and with the right know-how, you can mask your referrer to make it look like you’ve come from another website.