PHP code example of kirchdev / laravel-device-sessions
1. Go to this page and download the library: Download kirchdev/laravel-device-sessions library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kirchdev / laravel-device-sessions example snippets
$user->devices; // every browser signed in, with masked IP, OS and last-seen — GitHub-style
use KirchDev\DeviceSessions\Concerns\HasDeviceSessions;
class User extends Authenticatable
{
use HasDeviceSessions;
}
use KirchDev\DeviceSessions\Actions\{ListUserDevices, RevokeUserDevice, RevokeOtherUserDevices, UpdateUserDeviceName};
$devices = app(ListUserDevices::class)->execute($user); // active devices, last-seen first
app(RevokeUserDevice::class)->execute($user, $deviceId); // revoke one (+ its tokens)
app(RevokeOtherUserDevices::class)->execute($user, $currentId); // keep only the current device
app(UpdateUserDeviceName::class)->execute($user, $deviceId, 'Work Laptop');