Jump to content

Dynamic Redirect


karenn1

Recommended Posts

I have a website that caters for people from different areas in the city. Every area has it's own folder and unique pages. I want all of these people to log into one common members area. This prevents having several members area folders as well.

 

My problem is when you log out, I've got it hard coded to go to a specified page. How can I change that so that it redirects to the folder the person logged in from? Is there some sort of ROOT or SERVER ADDRESS code I can use? I've seen it before but I don't know how to use it.

 

 

Any help would be appreciated.

 

Thanks,

 

Karen

Link to comment
https://forums.phpfreaks.com/topic/55091-dynamic-redirect/
Share on other sites

Well as I understand you what I would do is keep a running track of what page they are on.

 

Say I'm in my domain and I'm on a page "page.php" in the directory "root/directory/"

 

If I run this variable $_SERVER['PHP_SELF'] it will return /directory/page.php.

 

Knowing that you can use a session to keep a running tab of what page they are on. Using something like:

 

session_start();
$_SESSION['referring_page'] = $_SERVER['PHP_SELF'];

 

Then on your redirect just use

 

header( 'location: ' . $_SESSION['referring_page'] );

 

Assuming you already declared session_start(); in the login script.

 

I would recommend against using REFERRER to track the page as it is often untrustworthy.

Link to comment
https://forums.phpfreaks.com/topic/55091-dynamic-redirect/#findComment-272443
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.