sess_expire_on_close not working

前端 未结 3 1770
我寻月下人不归
我寻月下人不归 2021-01-13 22:22

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

相关标签:
3条回答
  • 2021-01-13 22:49

    TRY to configure application/config/config.php

    $config['sess_expiration'] = 0;
    $config['sess_expire_on_close'] = TRUE;

    THIS should be OK

    0 讨论(0)
  • 2021-01-13 22:51

    The session closing will not erase the data in the database. It basically sets the value for session cookie lifetime to 0, meaning that the browser will delete the cookie when it closes (forcing a new session). The entry in the database table will not be cleaned up until garbage collection gets it, as, by default, there is no way for the browser to make a "callback" to the server to notify that it is closing so as to delete the session record in DB.

    For your purposes, you may want to define active users as users with records in DB less than your session lifetime in age.

    0 讨论(0)
  • 2021-01-13 23:00

    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.

    0 讨论(0)
提交回复
热议问题