yii2-session-timeout-warning
Users are warned about expiring session., (*1)
This is simple implementation of session timeout warning.
Plugin does not make any ajax calls, otherwise it would not work with many projects. Components like RBAC are using user identity all time and auth session is renewed every request., (*2)
This plugin writes and reads cookies., (*3)
It supports multiple tabs.
Plugin will not work if user is logged out from server side, or sessions are cleared from database., (*4)
If user session is expired, page will be reloaded., (*5)
Install
Either run, (*6)
$ php composer.phar require mg-code/yii2-session-timeout-warning "@dev"
or add, (*7)
"mg-code/yii2-session-timeout-warning": "@dev"
to the require
section of your composer.json
file., (*8)
Usage
1) Register bootstrap class in application config., (*9)
[
'bootstrap' => [
[
'class' => \mgcode\sessionWarning\components\SessionWarningBootstrap::className(),
'initMessages' => true,
]
],
];
initMesscompoages
property initializes translations.
Currently only English and Latvian languages are supported.
Please contribute and add your language., (*10)
2) Add controller to controllerMap in application config., (*11)
[
'controllerMap' => [
'session-warning' => [
'class' => 'mgcode\sessionWarning\controllers\SessionWarningController',
],
],
];
Note: If you are using RBAC, you should allow all visitors to access this controller., (*12)
3) Insert widget in layout view., (*13)
<?= \mgcode\sessionWarning\widgets\SessionWarningWidget::widget([
//... Properties ...
]); ?>
Properties:
* logoutUrl
- if is set, logout button will be shown before Continue button. Default: null
* extendUrl
- url where ajax request is sent, when continue button is clicked. Default: ['/session-warning/extend']
* warnBefore
- time in seconds before user is warned about expiring session. Default: 300 (5min), (*14)