1
votes

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;
    }
}
?>
2
Also share the code of validate function in login_model - Jigar Jain
this code is working fine in IE8.. but when i trying to do on IE7 .. redirect and session not working..it redirect me on Login page in IE7 - user1254919
there was on trouble in IE7 about session names with underscores _ have you tried renaming your cookie name and removing underscores? - tomexsans
Ya.. even i change the name as well...$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; - user1254919
As you're not using the database to store the session data, can you confirm that you haven't gone over the 4KB limit for the cookie? Might be causing a weird effect in IE7...? - PaulSkinner

2 Answers

1
votes

Add a site url in your redirect:

redirect(site_url('admin/show_admin_home'));
0
votes

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;