Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a problem..in $config['sess_expire_on_close'] = TRUE; when i close the browser..the session still save in the database. and i can still see the data in user_data column.

config.php

  $config['sess_cookie_name']     = 'ci_session';
  $config['sess_expiration']        = 2400;
   $config['sess_expire_on_close']  = TRUE;
  $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;

Need help.. the purpose is to show all online users.

I'm using CI version 2.1.3

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
620 views
Welcome To Ask or Share your Answers For Others

1 Answer

The server never knows about the user closing their browser. 'sess_expire_on_close' regards whether the user's cookie will be written and re-used when the browser is restarted.

To detect and end session, you'd have to perform a check like outlined in this question: javascript detect browser close tab/close browser

and then perform

$this->session->sess_destroy();

in codeigniter.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...