我想将codeigniter版本3中的会话设置为在浏览器关闭时过期。
我用谷歌搜索并得到了解决问题的解决方案。并在应用程序配置中更新到以下行
$config['sess_expiration'] = 0;
$config['sess_expire_on_close'] = TRUE;
此解决方案完美无缺。
但问题是,现在浏览器会话仍然直播,直到浏览器关闭,这将对我的应用程序有所帮助。
因此我想保持 10分钟的会话过期时间。
因此,请从论坛寻求帮助,以便在我的应用程序中实现这两种方案。
提前致谢。
答案 0 :(得分:0)
我认为您使用此代码,请转到:
var expireSessionVar = function(e){
//HERE YOUR CODE WHATEVER YOU WANT
};
window.unload = expireSessionVar;
希望它会对你有所帮助。
答案 1 :(得分:0)
<强>应用\设置\ config.php中强>
/*
|--------------------------------------------------------------------------
| Session Variables
|--------------------------------------------------------------------------
|
| 'sess_cookie_name' = the name you want for the cookie
| 'sess_expiration' = the number of SECONDS you want the session to last.
| by default sessions last 7200 seconds (two hours). Set to zero for no expiration.
| 'sess_expire_on_close' = Whether to cause the session to expire automatically
| when the browser window is closed
| 'sess_encrypt_cookie' = Whether to encrypt the cookie
| 'sess_use_database' = Whether to save the session data to a database
| 'sess_table_name' = The name of the session database table
| 'sess_match_ip' = Whether to match the user's IP address when reading the session data
| 'sess_match_useragent' = Whether to match the User Agent when reading the session data
| 'sess_time_to_update' = how many seconds between CI refreshing Session Information
|
*/
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 600;
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'dbapp_ci_sessions';
$config['sess_match_ip'] = TRUE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
/*
只需将$config['sess_expiration']= 7200;
设置为$config['sess_expiration'] = 600;
,这会将您的会话设置为每10分钟到期一次。此外,如果您将$config['sess_expire_on_close'] = TRUE;
设置为指向,则每次关闭浏览器时,会话将被终止。