-1

我有两个服务器 A 和 B 并且两个服务器都是相同的脚本,但是当我登录到服务器 A 登录页面时我想要重定向页面然后该页面自动重定向到服务器 B 登录页面是否可能?

4

3 回答 3

0

You really need to provide a bit more information. But, let me see if I can run through some scenarios.

First, let's assume that you login on either server, and you want it to goto an authenticated realm after login. This means you have to find a way to share the session between the two servers. You might consider creating the session store in a database that both servers can access. You'll still have to pass the session token from server A to server B after login.

Otherwise, if you're saying both servers are on the same domain, but each is a subdomain, you can choose to have your session cookie have a domain of the base domain - and all subdomains can access that session then. Still, the session data would either need to be stored in a database both servers had access to - ooorrr - mount a directory that both servers had access to.

Finally, if you want the user to login on either server A or B - but don't care about the authentication after you reach server B, then the solutions the other people provided will help.

My guess is you're trying to do some sort of single sign-on, so check into sharing your session among the servers. Please provide more information if you'd like a more pin-point answer.

于 2013-02-13T20:46:35.193 回答
0

使用 php 中可用的标头函数

$server_url='http://url-for-server-B';
header('Location: '.$server_url);
于 2013-02-13T17:40:31.140 回答
0
$yourlogincode ="SELECT WHATEVER FROM WHATEVER"; // do not forget to add your database type in here for example `mysql_query` 

if ($yourlogincode) 
{
//add your session code here
yourloginpagefromsiteB = "";
header('Location: '.$yourloginpagefromsiteB);
exit();
}
else
{
exit();
}
于 2013-02-13T18:19:51.957 回答