Question

I'm using codeigniter and have a simple user login setup. User submits their credentials, checks with the DB if they are valid, if they are the model passes the controller a session ID and is redirected to the user page. If the data is not correct the user is redirected to the login page with an error message. Nothing fancy here. The problems is it doesnt work in IE7. I'm not sure if its because of the redirect or the session creation. Works fine in all browsers except IE. I tested ie 8 with windows 7 on parallels and worked fine. The weird thing is that it doesnt work with on a pc with windows 7 IE7. Can someone tell me why the login page just keeps getting refreshed every time the user goes to login? I was told to try and add this code

$this->load->library('session');
        $this->load->model('login_model');
        $num_rows=$this->login_model->validate();
        if($num_rows == 1)
        {
            $data = array(          
            'is_logged_in' => true,         
            );

            $this->session->set_userdata($data);

            redirect('admin/show_admin_home');
        }
        else
        {
            $data['message']="चुकीचे युझर नेम अथवा पास वर्ड";
            $this->load->view('login',$data);
        }

Login Model Code :-

<?php

class Login_model extends CI_Model {



    function validate()
    {
        $username = $this->input->post('username');
        $password = $this->input->post('inputPassword');

        $this->db->select('*');     
        $this->db->where('login_username', $username);
        $this->db->where('login_password', $password);  
        $query = $this->db->get('login');
        return $query->num_rows;
    }
}
?>
Was it helpful?

Solution 2

Change Config setting

$config['sess_cookie_name'] = 'cisession'; $config['sess_expiration'] = 84200; $config['sess_expire_on_close'] = FALSE; $config['sess_encrypt_cookie'] = FALSE; $config['sess_use_database'] = FALSE; $config['sess_table_name'] = 'cisessions'; $config['sess_match_ip'] = FALSE; $config['sess_match_useragent'] = FALSE; $config['sess_time_to_update'] = 300;

OTHER TIPS

Add a site url in your redirect:

redirect(site_url('admin/show_admin_home'));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top