How to display session expiration message to the user (CodeIgniter framework)?

Viewed 58

How can I show notification to the user that a session is expired?

This is the config code:

$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);
2 Answers

i tried like this, It is worked for me!

echo $this->config->item('sess_expiration');

the Common function config_item() works pretty much everywhere throughout the CodeIgniter instance. Controllers, models, views, libraries, helpers, hooks.

echo config_item('sess_expiration'); // This is always work

OR you can use in view:

$ci = get_instance(); // CI_Loader instance
echo $ci->config->item('sess_expiration'); // sometime is it not work in view without instance
Related