What page did i come from???
Date: 03/20/05
(PHP Community) Keywords: php
I do a check at the start of every page to see of the user is logged in or not. If the user is not logged in I send them to the login page.
My client wants to be able to log in and then be taken directly to the page that they were trying to view before logging in.
I thought that I would be able to get the referring page from $_SERVER['HTTP_REFERER']but its blank when I ever I test for it. It works perfectly when I logout out of the system (this also sends you to the login page). It shows me the page that I logged out from.
So I am guessing that because you actually don't load the page you request before PHP processes whether you are logged in or not, it never gets stored in $_SERVER[''HTTP_REFERER'].
So my question is, how do I tell what page it came from?
Here is the code that handles sending you to a new page.
function verify_auth()
{
if(!auth_user($_SESSION['user']['AUTH'], $mode = 1))
{
$_SESSION['user'] = "";
header("Location: index.php");
}
}
* is there a way to post code and maintain formatting?
Source: http://www.livejournal.com/community/php/275479.html