php - Why in CodeIgniter redirect function is not working on live server, but working fine on localhost -


after installation. set login default controller , want go dashboard of admin after submitting login details instead of redirecting dashboard, redirecting install controller again.

can me?

my login controller login.php:

<?php if (!defined('basepath'))     exit('no direct script access allowed');  class login extends ci_controller {       function __construct()     {         parent::__construct();         $this->load->database();      }      /***default functin, redirects login page if no admin logged in yet***/     public function index()     {         if ($this->session->userdata('admin_login') == 1)             redirect(base_url() . 'index.php?admin/dashboard', 'refresh');          if ($this->session->userdata('doctor_login') == 1)             redirect(base_url() . 'index.php?doctor/dashboard', 'refresh');          if ($this->session->userdata('patient_login') == 1)             redirect(base_url() . 'index.php?patient/dashboard', 'refresh');          if ($this->session->userdata('nurse_login') == 1)             redirect(base_url() . 'index.php?nurse/dashboard', 'refresh');          if ($this->session->userdata('pharmacist_login') == 1)             redirect(base_url() . 'index.php?pharmacist/dashboard', 'refresh');          if ($this->session->userdata('laboratorist_login') == 1)             redirect(base_url() . 'index.php?laboratorist/dashboard', 'refresh');          if ($this->session->userdata('accountant_login') == 1)             redirect(base_url() . 'index.php?accountant/dashboard', 'refresh');            $config = array(             array(                 'field' => 'login_type',                 'label' => 'account type',                 'rules' => 'required|xss_clean'             ),             array(                 'field' => 'email',                 'label' => 'email',                 'rules' => 'required|xss_clean|valid_email'             ),             array(                 'field' => 'password',                 'label' => 'password',                 'rules' => 'required|xss_clean|callback__validate_login'             )         );          $this->form_validation->set_rules($config);         $this->form_validation->set_message('_validate_login', ucfirst($this->input->post('login_type')) . ' login failed!');         $this->form_validation->set_error_delimiters('<div class="alert alert-error">                                 <button type="button" class="close" data-dismiss="alert">×</button>', '</div>');          if ($this->form_validation->run() == false) {             $this->load->view('login');         } else {             if ($this->session->userdata('admin_login') == 1)                 redirect(base_url() . 'index.php?admin/dashboard', 'refresh');              if ($this->session->userdata('doctor_login') == 1)                 redirect(base_url() . 'index.php?doctor/dashboard', 'refresh');              if ($this->session->userdata('patient_login') == 1)                 redirect(base_url() . 'index.php?patient/dashboard', 'refresh');              if ($this->session->userdata('nurse_login') == 1)                 redirect(base_url() . 'index.php?nurse/dashboard', 'refresh');              if ($this->session->userdata('pharmacist_login') == 1)                 redirect(base_url() . 'index.php?pharmacist/dashboard', 'refresh');              if ($this->session->userdata('laboratorist_login') == 1)                 redirect(base_url() . 'index.php?laboratorist/dashboard', 'refresh');              if ($this->session->userdata('accountant_login') == 1)                 redirect(base_url() . 'index.php?accountant/dashboard', 'refresh');         }      }      /***validate login****/     function _validate_login($str)     {         if ($this->input->post('login_type') == '') {             $this->session->set_flashdata('flash_message', get_phrase('login_failed'));             return false;         }         $query = $this->db->get_where($this->input->post('login_type'), array(             'email' => $this->input->post('email'),             'password' => $this->input->post('password')         ));         if ($query->num_rows() > 0) {             $row = $query->row();             if ($this->input->post('login_type') == 'admin') {                 $this->session->set_userdata('login_type', 'admin');                 $this->session->set_userdata('admin_login', '1');                 $this->session->set_userdata('admin_id', $row->admin_id);             }             if ($this->input->post('login_type') == 'doctor') {                 $this->session->set_userdata('login_type', 'doctor');                 $this->session->set_userdata('doctor_login', '1');                 $this->session->set_userdata('doctor_id', $row->doctor_id);             }             if ($this->input->post('login_type') == 'patient') {                 $this->session->set_userdata('login_type', 'patient');                 $this->session->set_userdata('patient_login', '1');                 $this->session->set_userdata('patient_id', $row->patient_id);             }             if ($this->input->post('login_type') == 'nurse') {                 $this->session->set_userdata('login_type', 'nurse');                 $this->session->set_userdata('nurse_login', '1');                 $this->session->set_userdata('nurse_id', $row->nurse_id);             }             if ($this->input->post('login_type') == 'pharmacist') {                 $this->session->set_userdata('login_type', 'pharmacist');                 $this->session->set_userdata('pharmacist_login', '1');                 $this->session->set_userdata('pharmacist_id', $row->pharmacist_id);             }             if ($this->input->post('login_type') == 'laboratorist') {                 $this->session->set_userdata('login_type', 'laboratorist');                 $this->session->set_userdata('laboratorist_login', '1');                 $this->session->set_userdata('laboratorist_id', $row->laboratorist_id);             }             if ($this->input->post('login_type') == 'accountant') {                 $this->session->set_userdata('login_type', 'accountant');                 $this->session->set_userdata('accountant_login', '1');                 $this->session->set_userdata('accountant_id', $row->accountant_id);             }             return true;         } else {             $this->session->set_flashdata('flash_message', get_phrase('login_failed'));             return false;         }     }     /*******logout function *******/     function logout()     {         $this->session->unset_userdata();         $this->session->sess_destroy();         $this->session->set_flashdata('flash_message', get_phrase('logged_out'));         redirect(base_url() . 'index.php?login', 'refresh');     }      /***default nor found page*****/     function four_zero_four()     {         $this->load->view('four_zero_four');     }      /***reset , send password requested email****/     function reset_password()     {         $account_type = $this->input->post('account_type');         if ($account_type == "") {             redirect(base_url(), 'refresh');         }         $email  = $this->input->post('email');         $result = $this->email_model->password_reset_email($account_type, $email); //send email account opening email         if ($result == true) {             $this->session->set_flashdata('flash_message', get_phrase('password_sent'));         } else if ($result == false) {             $this->session->set_flashdata('flash_message', get_phrase('account_not_found'));         }       }      /***login user doctor,patient,pharmacist,laboratorist etc******/     function login_as($user_type = '', $user_id = '')     {         $this->session->set_userdata('login_type', $user_type);         $this->session->set_userdata($user_type . '_login', '1');         $this->session->set_userdata($user_type . '_id', $user_id);         redirect(base_url() . 'index.php?' . $user_type . '/dashboard', 'refresh');     } } 

did check cookie in live server? had experienced similar yours. redirect() function not work in live server, in fact thing doesn't work user_data session has gone everytime page loaded. allowed cookie $config['sess_cookie_name'] = "my-cookie*******" in live server , goes well.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -