EllisLab text mark
Advanced Search
     
Session not expire on Google Chrome
Posted: 20 November 2012 03:59 PM   [ Ignore ]
Joined: 2012-11-20
3 posts

Here are my settings:

$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

 
Posted: 21 November 2012 01:50 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2009-05-17
1415 posts

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.

 Signature 

Brian
Brian’s Web Design - Temecula
Community Auth - CodeIgniter Authentication Application

 
Posted: 21 November 2012 02:23 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6267 posts
$config['sess_time_to_update'1// ?????? 

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.

 

 Signature 

Ceritfied State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

 
Posted: 21 November 2012 08:16 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2012-11-20
3 posts

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:

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) ? 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:

$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
 
Posted: 22 November 2012 06:45 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Joined: 2012-11-20
3 posts

Any ideas?
The way I see it, it is a Chrome bug. Hasn’t anyone of you seen the same issue?