Page 1 of 1

login

Posted: Tue Feb 08, 2005 1:24 pm
by ohnder
I'm rather new to PHP.. so this may be a simple question..
I have a members area..which works fine.. but after login (from any restricted page) the user is sent to the front page:
<META HTTP-EQUIV=Refresh CONTENT="2; URL=index.php">
This line is included in one of the config files.

Can I somehow sent them to the page they were accessing in first place?

Thanks in advance!

Posted: Tue Feb 08, 2005 3:06 pm
by PrObLeM

Posted: Tue Feb 08, 2005 3:08 pm
by feyd
it's best to avoid relying on http_referer, as it's an optiona request header component.

When I have needed to redirect back to page of incep, I passed the url to redirect back to.. either encoded via some method or not..

Posted: Tue Feb 08, 2005 3:11 pm
by Burrito
what I do is include an "application.php" file on all of my pages I want secured.

In there I set session vars. If the loggedin session var isn't set then I send them to the login screen and pass the page they were on in the url string. Then when they log in, I point them to the page they were on.

see code ex. below:

Code: Select all

<? 
error_reporting(E_ERROR);
if(!isset($_SESSION&#1111;"loggedin"]))&#123;
	$location = "http://".$_SERVER&#1111;"SERVER_NAME"].$_SERVER&#1111;"PHP_SELF"].(isset($_SERVER&#1111;'QUERY_STRING']) ? '?' . $_SERVER&#1111;'QUERY_STRING'] : '');
	
?>
Burr