Home > Backend Development > PHP Tutorial > PHP 应用session对两个不同的服务器网站进行同步登录

PHP 应用session对两个不同的服务器网站进行同步登录

WBOY
Release: 2016-06-13 12:40:14
Original
899 people have browsed it

PHP 使用session对两个不同的服务器网站进行同步登录
现在有两个服务器
a:www.test1.com
b:www.test2.com
我想在test1里面进行登录,然后在test2里面也同样进行登录,请问这个该怎么写?

我有部分测试代码如下
在test1登录的时候,如果登录成功那么就执行下面

$fp = pfsockopen("www.test2.com",80,$errorno,$errormsh);//连接服务器<br />
		if ($fp){<br />
    			$out = "GET /login.php?acc=".$acc."&psw=".$psw." HTTP/1.1\r\n";   <br />
    			$out.= "Host:www.test2.com\r\n";   <br />
    			$out.= "Connection: Close\r\n\r\n";   <br />
     <br />
    			fputs($fp, $out);<br />
    			fclose($fp);   <br />
		}
Copy after login


然后在www.test2.com里面的login.php文件
$acc = $_GET['acc'];<br />
$psw = $_GET['psw'];<br />
$_SESSION['acc'] = $acc;<br />
$_SESSION['psw'] = $psw;
Copy after login


然后我访问www.test2.com
发现session为空啊  
求高手指教!

PHP session 跨域? 登录?
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template