Every browser sends a referer in the header. (The HTTP header contains additional information about you and the webpage you’re requesting). The referer is the site you’ve been on before requesting the current site. That means you can see where people came from. Here is a nice and effective technique on how you can use the referer in a web application.
You are on a typical website. Let’s say Jobazaar. You’re logged in. You want to log out. But, wait, you just want to log out, not leaving the page you’re currently viewing. Uhmm.. it’s Jobazaar, so just click “log out”.
What happens? You get the same page, you’re just not logged in anymore. Some magic caused by the referer in the HTTP header. Remeber: We are not passing any arguments through the URL.
This is what happens in the logout script:
....
(some magic things you'll never get to know)
....
if(@$_SERVER['HTTP_REFERER'] != '')
header('Location: '.$_SERVER['HTTP_REFERER']);
else
header('Location: http://www.example.com/');
....
header('Location: ...');
does a 302 redirect to the specified site. The user will not notice any redirecting.
These are four lines that can make a huge improvement on usability. It�s the small things that count. People won’t take much notice of this improvement, but they have a better experience when surfing your site since they don’t have to navigate back to the point they’ve been on when logging out.
I’ve to say that there are areas on a website where you can’t get back to after logging out. That’s no problem, because those ‘areas’ should automatically redirect you to some ‘safe’ place. No improvement there, however.