barchart/laravel-remember-all

A Laravel session driver to remember all devices a user has logged in with.

v1.3.0 2022-09-30 11:30 UTC

This package is auto-updated.

Last update: 2024-03-29 03:44:50 UTC


README

Laravel currently only supports the "remember me" feature for one device. When you log in to multiple devices, then log out of one, you will be logged out of all. This solves that by storing the tokens in a separate table.

There is a current proposal to put this into Laravel core, but we needed this now: laravel/ideas#971

Setup

Install via composer:

composer require barchart/laravel-remember-all

Migrate the new remember_tokens table:

php artisan migrate

Update your authentication guard:

'guards' => [
    'web' => [
        'driver' => 'rememberall',
        'provider' => 'users',
        'expire' => 10080, // optional token expiration time, in minutes (7 days is the default)
    ],
],

Eloquent

For Eloquent, you also need to update your model. Just replace Laravel's default User model with the following:

use Barchart\Laravel\RememberAll\User as Authenticatable;

class User extends Authenticatable
{

}

If you're not extending off of Laravel's base User model and instead extending directly off of Eloquent's Model, replace Laravel's default Authenticatable and AuthenticatableContract with the following:

use Barchart\Laravel\RememberAll\EloquentAuthenticatable as Authenticatable;
use Barchart\Laravel\RememberAll\Contracts\Authenticatable as AuthenticatableContract;

class User extends Model implements AuthenticatableContract
{
    use Authenticatable;
}