A plugin provide single session authentication for Laravel 5.
$ composer require overtrue/laravel-single-session -vvv
- Register provider(if you disabled Laravel auto discovery)
'providers' => [
Overtrue\LaravelSingleSession\SingleSessionServiceProvider::class
],
- (Optional) Config the session:
// config/session.php
// The storage for store the last session id.
'last_session_storage' => 'cache', // cache(default)/database
// The field name of last session id.
'last_session_field' => 'last_session_id',
// The path of redirect when logout after session changed.
'redirect_path' => '/',
- it works.
If the session changed, the following event will be triggered:
Overtrue\LaravelSingleSession\Events\SessionExpired
MIT