[eluser]mvdg27[/eluser]
Hi,
I have a very simple login script using CI's session class. Most users don't experience any problems, but a few of them do, all located in another country and timezone (my server is based in the Netherlands, and the users are based in Brazil) login.
Whenever they login, the session is lost when refreshing the page. I checked if they allow cookies. Could this timezone difference be causing the problems? And if so, is there a solution for this problem?
For reference, I've added the login function (uses ajax technology, by the way) and my session config.
Code:
function do_login($user_input) {
$query = $this->CI->db->getwhere('users', array('username' => $user_input['username'], 'password' => md5($user_input['password'])));
if($query->num_rows()) {
$user_data = $query->first_row('array');
$this->CI->db->where('id', $user_data['id']);
$this->CI->db->set('logindate', date('Y-m-d H:i:s'));
$this->CI->db->update('users');
$this->CI->session->set_userdata('userid', $user_data['id']);
$data['username'] = $user_input['username'];
$this->objResponse->Assign("login","innerHTML", $this->CI->load->view('loggedin', $data, true));
}
else {
$this->objResponse->alert('Sorry, login incorrect. Please try again!');
}
return $this->objResponse;
}
Code:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
Thanks in advance!
Cheers, Michiel