如何向用户显示会话已过期的通知?
这是配置代码:
$config['sess_driver'] = SESS_DRIVER;
$config['sess_cookie_name'] = (defined('APP_SESSION_COOKIE_NAME') ? APP_SESSION_COOKIE_NAME : 'sp_session');
$config['sess_expiration'] = (defined('APP_SESSION_EXPIRATION') ? APP_SESSION_EXPIRATION :30);
$config['sess_save_path'] = SESS_SAVE_PATH;
$config['sess_match_ip'] = (defined('APP_SESSION_MATCH_IP') ? APP_SESSION_MATCH_IP : false);
$config['sess_time_to_update'] = (defined('APP_SESSION_TIME_TO_UPDATE') ? APP_SESSION_TIME_TO_UPDATE : 30);
$config['sess_regenerate_destroy'] = (defined('APP_SESSION_REGENERATE_DESTROY') ? APP_SESSION_REGENERATE_DESTROY : false);
我试过这样做,它对我有用!
echo $this->config->item('sess_expiration');
公共函数config_item((在整个CodeIgniter实例中几乎无处不在。控制器、模型、视图、库、助手、钩子。
echo config_item('sess_expiration'); // This is always work
或者您可以在视图中使用:
$ci = get_instance(); // CI_Loader instance
echo $ci->config->item('sess_expiration'); // sometime is it not work in view without instance