1.准备两个虚拟域名
127.0.0.1 www.a.com
127.0.0.1 www.b.com
2.在a的根目录下创建以下文件
1 //index.php 2 3 <?php 4 session_start(); 5 ?> 6 <!DOCTYPE html> 7 <html> 8 <head> 9 <meta charset="UTF-8"/> 10 <title>sync login</title> 11 </head> 12 <body> 13 14 <?php if(empty($_SESSION['username'])):?> 15 <p>hello,游客;请先<a href="login.php">登录</a></p> 16 <p><a href="http://www.b.com/index.php">进入空间</a></p> 17 <?php else: ?> 18 <p>hello,<?php echo $_SESSION['username']; ?>;<a href="http://www.b.com/index.php">进入空间</a></p> 19 <?php endif; ?> 20 <a href="http://www.a.com/index.php">home</a> 21 </body> 22 </html> 23 24 //login.php 25 <?php 26 session_start(); 27 if(!empty($_POST['username'])){ 28 require './Des.php'; 29 $_SESSION['username'] = $_POST['username']; 30 $redirect = 'http://www.a.com/index.php'; 31 header('Location:http://www.a.com/sync.php?redirect='.urlencode($redirect).'&code='.Des::encode($_POST['username'],'a')); 32

最低0.47元/天 解锁文章
525

被折叠的 条评论
为什么被折叠?



