I developed website on php framework (Codeigniter) that working fine on my local (WAMP Server). When I upload it to Godaddy hosting, it unable to login into website. Below is the login class function.
public function index()
{
if ($this->session->userdata('admin_login') == 1)
redirect(base_url() . 'index.php?admin/dashboard', 'refresh');
$this->load->view('backend/login');
}
function ajax()
{
$response = array();
$email = $_POST["email"];
$password = $_POST["password"];
$response['submitted_data'] = $_POST;
$login_status = $this->validate_login( $email , sha1($password) );
$response['login_status'] = $login_status;
if ($login_status == 'success') {
$response['redirect_url'] = '';
}
echo json_encode($response);
}
function validate_login($email = '' , $password = '')
{
$credential = array( 'email' => $email , 'password' => $password );
$query = $this->db->get_where('users' , $credential);
if ($query->num_rows() > 0) {
$row = $query->row();
$this->session->set_userdata('admin_login', '1');
$this->session->set_userdata('admin_id', $row->id);
$this->session->set_userdata('name', $row->name);
$this->session->set_userdata('login_type', 'admin');
return 'success';
}
return 'invalid';
}
I realize that $this->session->set_userdata() method is not working on godaddy.
Please try this
Please add session library just like below.
$this->load->library('session');
if ($this->session->userdata('admin_login') == 1)
redirect(base_url() . 'index.php?admin/dashboard', 'refresh');
$this->load->view('backend/login');
First Load Session Library then Instead of Using this
if ($this->session->userdata('admin_login') == 1)
Use This
if ($this->session->userdata['admin_login'] == 1)
Check if it is working or not
Try a few alternatives may work:
Change these lines in application/config/config.php
$config['sess_cookie_name'] = 'cisession'; //remove(underscore)
$config['cookie_domain'] = ".example.com"; //make it site wide valid
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With