Welcome Guest, Not a member yet? Register   Sign In
CI fails to create session
#1

[eluser]zsela[/eluser]
Hi everybody!

I hope you can help me with my very strange problem: I have a login function in my user controller which fails to build up the session, but only with Chrome and IE. On Firefox, it works fine.

Here is the function:

Code:
function login() {
  
  $this->form_validation->set_rules('username', 'Felhasználónév', 'trim|required|xss_clean');
  $this->form_validation->set_rules('pwd', 'Jelszó', 'trim|required|xss_clean');
  
  $this->form_validation->set_error_delimiters('<p class="error">', '</p>');
  
  if($this->form_validation->run() == FALSE) {
   // didn't run, or with errors
   $this->load->view('user/login');
  } else {
   //everything is OK
   $username = $this->input->post('username');
   $pwd = $this->input->post('pwd');
  
   $user_data = $this->User_model->check_login($username, $pwd);
   $ID = $user_data->ID;
   $user_name = $user_data->user_name;
   $rank = $user_data->rank;
   $activated = $user_data->activated;  
  
   if( !$user_data ) {
    //login failed
    $this->session->set_flashdata('login_error', 'unknown_user');
    redirect('user/login');

   } elseif ( $activated != 1 ) {
    //inactive user
    $this->session->set_flashdata('login_error', 'inactive_user');
    redirect('user/login');
    
   } else {
    //log the user in
    $login_data = array(
     'logged_in' => TRUE,
     'ID'  => $ID,
     'username' => $user_name,
     'rank'  => $rank
    );
    
    // felhasználó jogsultságai session data-ba
    $user_rights = array();
    $i = 0;
    $result = $this->User_model->check_rights($username);
    
    if ($result){
     foreach ($result->result() as $row) {
      $user_rights[$i] = $row->action;
      $i++;
     }
    }
    
    $login_data['rights'] = $user_rights;
    $this->session->set_userdata($login_data);
    
    //check where the user came from
    if($this->session->userdata('source_page')) {
     redirect($this->session->userdata('source_page'));
    } else {
     redirect('user/profile/' . $user_name);
    }
   }
  }
}

My session settings from the config file:

Code:
$config['sess_cookie_name']  = 'ci_session';
$config['sess_expiration']  = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name']  = 'session';
$config['sess_match_ip']  = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;

The strange thing is when I reload the login page I can see in the database that a new record is created for every try when using Chrome and IE, but not with Firefox.

This login function was working yesterday evening and I dont remember if I changed anything. Prety strange.

Please help me with that, I am out of ideas!
Thanks for your answers in advance!


Messages In This Thread
CI fails to create session - by El Forum - 02-09-2012, 09:34 AM
CI fails to create session - by El Forum - 02-09-2012, 11:47 AM
CI fails to create session - by El Forum - 02-09-2012, 12:02 PM
CI fails to create session - by El Forum - 02-10-2012, 01:08 AM
CI fails to create session - by El Forum - 02-10-2012, 04:04 AM
CI fails to create session - by El Forum - 02-10-2012, 04:41 AM
CI fails to create session - by El Forum - 02-13-2012, 10:59 AM
CI fails to create session - by El Forum - 02-13-2012, 11:20 AM
CI fails to create session - by El Forum - 02-13-2012, 11:43 AM
CI fails to create session - by El Forum - 03-04-2012, 04:13 AM
CI fails to create session - by El Forum - 03-04-2012, 08:42 AM
CI fails to create session - by El Forum - 03-04-2012, 08:50 AM
CI fails to create session - by El Forum - 03-04-2012, 09:31 AM
CI fails to create session - by El Forum - 03-05-2012, 10:34 AM
CI fails to create session - by El Forum - 03-06-2012, 02:27 PM
CI fails to create session - by El Forum - 03-06-2012, 02:57 PM
CI fails to create session - by El Forum - 03-06-2012, 03:03 PM
CI fails to create session - by El Forum - 03-06-2012, 04:15 PM
CI fails to create session - by El Forum - 03-07-2012, 10:06 AM
CI fails to create session - by El Forum - 03-08-2012, 02:04 AM
CI fails to create session - by El Forum - 03-13-2012, 10:52 AM
CI fails to create session - by El Forum - 03-13-2012, 10:56 AM
CI fails to create session - by El Forum - 03-13-2012, 11:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB