Page 1 of 1

On authentication, how to redirect to one of 20 websites?

Posted: Sat Jan 09, 2010 2:10 pm
by leew1954
I have over 20 web sites. They all use a central members database. Upon registration and/or login, I want the user to go the appropriate site, based on one of the fields in the database (state). Because they are all using the same dB for authentication, they would be able to log in from any of the sites and go to their specific site.

Right now it sort of works, but they all go to the same site because of the way it is set up and I can't quite get my head around how to make it do what I want.

Here is what I have now.
Upon authentication (uname and pword), $loginsuccess="a specific site" -- this works

I want it to be:
Upon authentication, $loginsuccess="one of the 20 sites, but the one that is specific to their state as indicated in the dB"

HERE IS THE CODE:
setcookie ("USERNAME", $_POST['username'],0,'/');
setcookie ("PASSWORD", $_POST['password'],0,'/');

include_once ("auth.php");
include_once ("authconfig.php");

$username = $_POST['username'];
$password = $_POST['password'];

$Auth = new auth();
$detail = $Auth->authenticate($username, $password);

if ($detail==0)
{
?><HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $stateloginfailure; ?>");
//-->
</SCRIPT>
</HEAD>
<?
}
elseif ($detail['team'] == "Admin") {
?><HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $admin; ?>");
//-->
</SCRIPT>
</HEAD>
<?
}
elseif ($detail['team'] == "Admin") {
?><HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $success; ?>");
//-->
</SCRIPT>
</HEAD>
<?
}
else
{
?><HEAD>
<SCRIPT language="JavaScript1.1">
<!--
location.replace("<? echo $loginsuccess; ?>");
//-->
</SCRIPT>
</HEAD>
<?
}
?>
___________-
$loginsuccess is in the authconfig.php file, where my connection to the dB is also. (Auth.php, authconfig.php, and my actual authenticationcheck.php files are already included.)

This works, but isn't what I want.
$loginsuccess = "http://127.0.0.1/somesite/home.html"; // PAGE SHOWN IF USER IS AUTHENTICATED

I would like it to ge:
$loginsuccess="one of the 20 sites, but the one that is specific to their state as indicated in the dB"

for example:
If state=Alabama, GoTo site1
elseif state=Minnesota, GoTo site2
elseif state=New York, site3
etc.
---------------
What, if anyone can help, should I actually be coding?

Thanks in advance.

Re: On authentication, how to redirect to one of 20 websites?

Posted: Sat Jan 09, 2010 4:25 pm
by omniuni
since sites (should not be able to) read each other's cookies, you'll need to take their information, redirect to a login page on the other websites, deliver appropriate headers to log the person in, have those headers processed, and log them in on said site.

Re: On authentication, how to redirect to one of 20 websites?

Posted: Sat Jan 09, 2010 5:16 pm
by leew1954
I guess I don't understand?! As it now stands, I can go to the parent site (where all member registration is done), and they register and redirected ($loginsuccess) to to site1/homepage upon successful registration.

They then can log in to site1 from the "parent" registration site, as well as from site1/index page (which is the same as site1 login page, which then takes them into the site1/home page). It works.

So, $loginsuccess should work for any of the sites, if I can code it correctly, which is where I am having trouble.