我在codeigniter上遇到会话数据丢失问题。当用户登录时,它会存储会话数据,但是一旦用户转到另一个页面,会话数据就会丢失。什么能引起这种情况?当我切换到站点ssl时出现此问题。
配置文件:
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = FALSE;
$config['cookie_httponly'] = FALSE;
$config['base_url'] = 'https://blabla.com/';
登录过程
public function login_user_process(){
$params = [
'user_email' => $this->input->post('user_email'),
'password' => $this->input->post('user_pass')
];
$this->load->library('form_validation');
$this->form_validation->set_rules('user_email', 'E-Posta', 'required');
$this->form_validation->set_rules('user_pass', 'Password', 'required');
if ($this->form_validation->run() == false) {
$this->session->set_flashdata('status', '0');
$this->session->set_flashdata('msg', 'Username and password field can not be null.');
redirect('login', 'refresh');
}
$check_activation = $this->db->where('user_email', $params['user_email'])->get('aj_users')->row_array();
if ( $check_activation['activation_code'] != null ){
$this->session->set_flashdata('status', '0');
$this->session->set_flashdata('msg', 'Please active your account by email we have sent on registration. If you can not reach activation email please click <a href="'.base_url().'resend_activation" class="resendActivation">resend activation code</a>');
redirect('login', 'refresh');
}
$query = $this->index_model->loginCheck($params['user_email'], $params['password']);
if ( $query != null ){
$session_data = array(
'email' => $params['user_email'],
'user_role' => $query['user_role'],
'is_logged' => 1,
'agent' => $_SERVER ['HTTP_USER_AGENT'],
'user_id' => $query['table_id']
);
$this->session->set_userdata($session_data);
if ( $query['user_role'] == 'OPERATOR' ){
redirect('../operators/profile_edit', 'refresh');
}
if ( $query['user_role'] == 'USER' ){
redirect('../user/my_account', 'refresh');
}
}else{
$this->session->set_flashdata('status', '0');
$this->session->set_flashdata('msg', 'Wrong username and password.');
redirect('login', 'refresh');
}
它正在开发非ssl版本。现在它无法正常工作。