xiunoPHP实现同步登陆 折腾教程

Lv.2 若如初 2022-5-14 3637

利用主站校验,跳转回来
<?php$action = param(1);if($action == 'login') {
         
        $_SESSION['referer'] = http_referer();
         
        // 发起的 token
        $token = xn_encrypt($time."\t".$useragent);
        $s = xn_decrypt($token);
        $return_url = xn_urlencode(http_url_path().url('user-synlogin'));
        http_location(BBS_URL."user-synlogin.htm?token=$token&return_url=$return_url");
         // 接受跳转回来的 token} elseif($action == 'synlogin') {
         
        $token = param('token');
        $s = xn_decrypt($token);
        $arr = xn_json_decode($s);
        empty($arr) AND message(-1, 'TOKEN 有错误');
         
        $_SESSION['uid'] = $arr['uid'];
        $_SESSION['user'] = $arr;
         
        $referer = $_SESSION['referer'];
        unset($_SESSION['referer']);
         
        message(-1, jump('登陆成功', $referer, 2));
         } elseif($action == 'create') {
         
        http_location(BBS_URL.url("user-create"));
         } elseif($action == 'logout') {
         
        $uid = 0;
        unset($_SESSION['uid']);
        unset($_SESSION['user']);
        message(-1, jump('退出成功', http_referer(), 2));
         }?>​
──── 0人觉得很赞 ────
最新回复 (0)
返回