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