Git Product home page Git Product logo

yii2-session-timeout-warning's Introduction

yii2-session-timeout-warning

Users are warned about expiring session.

Differences with original code

  1. Added support of Russian and Ukrainian languages

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.

This plugin writes and reads cookies.

It supports multiple tabs. Plugin will not work if user is logged out from server side, or sessions are cleared from database.

If user session is expired, page will be reloaded.

Install

Either run

$ php composer.phar require dennis-kashirin/yii2-session-timeout-warning "@dev"

or add

"dennis-kashirin/yii2-session-timeout-warning": "@dev"

to the require section of your composer.json file.

Usage

  1. Register bootstrap class in application config.
[
  'bootstrap' => [
      [
          'class' => \mgcode\sessionWarning\components\SessionWarningBootstrap::className(),
          'initMessages' => true,
      ]
  ],
];

initMesscompoages property initializes translations. Currently only English, Latvian, Russian and Ukrainian languages are supported. Please contribute and add your language.

  1. Add controller to controllerMap in application config.
[
  'controllerMap' => [
    'session-warning' => [
      'class' => 'mgcode\sessionWarning\controllers\SessionWarningController',
    ],
  ],
];

Note: If you are using RBAC, you should allow all visitors to access this controller.

  1. Insert widget in layout view.
<?= \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)

yii2-session-timeout-warning's People

Contributors

mg-code avatar dennis-kashirin avatar romanrabirokh avatar paskuale75 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.