<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
craftsys / laravel-redis-session-enhanced example snippets
'providers' => [
// Other service providers...
Craftsys\LaravelRedisSessionEnhanced\RedisSessionEnhancedServiceProvider::class,
],
[
'redis' => [
// ... existing configuration
// Add new connection for session
'session' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
// new DB, only for sessions for quick access and cleanup, change the value if 2 is already taken
'database' => env('REDIS_CACHE_DB', 2),
],
]
];
use Craftsys\LaravelRedisSessionEnhanced\SessionHelper;
// 1. Show the active/all sessions of a User
SessionHelper::getForUser($user_id) // get collection of all sessions of a user
SessionHelper::getForUser($user_id, true) // get collection of all active sessions of a user
// 2. Remove all/other sessions of a user
SessionHelper::deleteForUserExceptSession($user_id, [request()->session()->id]) // delete user's sessions except the current request
SessionHelper::deleteForUserExceptSession($user_id) // delete all sessions of a user
// 3. Remove All sessions (can be used in a command to flush out all sessions by DevOps)
SessionHelper::deleteAll() // delete all the sessions stored in database of every
// 4. Check if the application is configured with valid driver (database/redis).
SessionHelper::isUsingValidDriver() // return true if using SESSION_DRIVER=database or SESSION_DRIVER=redis-session
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.