Welcome Guest, Not a member yet? Register   Sign In
Session not expire on Google Chrome
#1

[eluser]barakuda28[/eluser]
Here are my settings:

Code:
$config['sess_cookie_name']  = 'ci_session';
$config['sess_expiration']  = 0;
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = FALSE;
$config['sess_table_name']  = 'ci_sessions';
$config['sess_match_ip']  = TRUE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 1;

I tested in Opera, Firefox, Safari and Chrome. Only under Chrome the session cookie does not expire on browser close.

I am not sure if this is a CodeIgniter bug, or a Chrome bug (more likely), but I wanted to hear your thoughts on the matter Smile
#2

[eluser]skunkbad[/eluser]
This is not a Chrome bug or a CodeIgniter bug. This is a bug in your code. If you would please show us some simple code, we can probably verify that that is the case. You can probably prove it to yourself by simplifying your code to the bare minimum for testing the session.
#3

[eluser]InsiteFX[/eluser]
Code:
$config['sess_time_to_update'] = 1; // ??????

Quote:sess_time_to_update 300 Time in seconds

This options controls how often the session class will regenerate itself and create a new session id.
#4

[eluser]barakuda28[/eluser]
My code is pretty simple.
As I said, the session cookie does not get deleted only under Chrome, so I don't see how this can be a bug in my code.

Here is some part of it:

Code:
public function is_logged_in() {
  $cookie = unserialize($this->input->cookie('auth'));
  $session = unserialize($this->session->userdata('auth'));

  if (!$cookie && !$session) {
   return 0;
  } else {
   $stored=($cookie) ? $cookie : $session;
  }

  $query_result = $this->db->select('password, date_created')->from('users')->where('username', $stored['username'])->get()->result()[0];
  $generated_auth = sha1($query_result->password . $query_result->date_created);
  
  return ($stored['auth'] == $generated_auth) ? 1 : 0;
}

public function login() {
  $login_data=$this->input->post('login');

  if ($login_data) {
   $query_result = $this->db->select('username, password, date_created')->from('users')->where('username', $login_data['username'])->get()->result()[0];

   if (sha1($login_data['password']) == $query_result->password) {

    $generated_auth=serialize(array(
     'username' => $query_result->username,
     'auth' => sha1($query_result->password . $query_result->date_created)
    ));

    if (isset($login_data['remMe'])) {
     $this->input->set_cookie(array(
      'name' => 'auth',
      'value' => $generated_auth,
      'expire' => 14*24*60*60
     ));
    } else {
     $this->session->set_userdata('auth', $generated_auth);
    }
   }
  }
}

And here are my settings, a little changed:
Code:
$config['sess_cookie_name']  = 'session';
$config['sess_expiration']  = 0;
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = FALSE;
$config['sess_table_name']  = 'sessions';
$config['sess_match_ip']  = TRUE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
#5

[eluser]barakuda28[/eluser]
Any ideas?
The way I see it, it is a Chrome bug. Hasn't anyone of you seen the same issue?




Theme © iAndrew 2016 - Forum software by © MyBB