doubingjian2006 2019-05-11 05:08
浏览 57

如何登录两个不同的codeigniter项目

I have two different CodeIgniter project first is on a root domain and another one is one subdomain.

I try to use the existing login function of both the projects, I put my multi-login code in subdomain its work fine

Checking whether it's available or not in a subdomain or if not present check the root domain database

after submitting the form it comes here in checkUser()

 function checkUser(){  

             $username = $this->input->post('username');  
             $password = $this->input->post('password');

             $this->load->model('CheckUserModel');
             $data = $this->CheckUserModel->checkUser($username,$password);
  if($data['user']['instance']=="sub-domain"){
            print_r("Inside Subdomain instance");


        //Model Function
        $this->load->model('login_model');

        if ($this->login_model->can_login_valid($username,$password)) {

            $data = $this->login_model->can_login($username,$password);


               redirect(base_url());
            //redirect(base_url().'user/SigninController/enter');
        }else {

            $this->session->set_flashdata('error','Invalid Username and Password');
            redirect(base_url().'user/CheckUserContoller/');
        }


      }else if($data['user']['instance']=="root-domain"){
            print_r("Inside root-doamin instance");


        //Model Function
        $this->load->model('login_model');


        if ($this->login_model->can_login_valid2($username,$password)) {

            $data = $this->login_model->can_login2($username,$password);


              //load the Curl library
              $this->load->library('curl');       

              //Request using POST Method
              $url = 'https://root-domain.online/user/SigninController/';     
              $postData= array(

                           "user_email" => $username,
                           "user_password" => $password,
                           'redirect_to' => $url,
                           'testcookie' => '1'
                        );


            curl_setopt_array($ch, array(
                CURLOPT_URL => 'https://root-domain.online/user/SigninController/login_validation',
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_POST => true,
                CURLOPT_POSTFIELDS => $postData,
                CURLOPT_FOLLOWLOCATION => true
            ));

            $output = curl_exec($ch);
            echo $output;

            //redirect(base_url().'user/SigninController/enter');
        }else {

            $this->session->set_flashdata('error','Invalid Username and Password');
            redirect(base_url().'user/CheckUserContoller/');
        }
         }
}

it works fine in a subdomain and logged in me

but the problem is that when I try to login to root domain it shows the login page

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
    • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
    • ¥60 pb数据库修改与连接
    • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
    • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
    • ¥20 神经网络Sequential name=sequential, built=False
    • ¥16 Qphython 用xlrd读取excel报错
    • ¥15 单片机学习顺序问题!!
    • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
    • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)