Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Authentication Log Laravel Package

rappasoft/laravel-authentication-log

View on GitHub
Deep Wiki
Context7

title: Session Management weight: 3

The package provides comprehensive session management capabilities, allowing you to view and manage active user sessions.

Getting Active Sessions

Get all active sessions for a user:

$user = User::find(1);

// Get active sessions collection
$activeSessions = $user->getActiveSessions();

// Get count of active sessions
$sessionCount = $user->getActiveSessionsCount();

// Get active sessions query builder (for further filtering)
$activeSessionsQuery = $user->activeSessions();

Revoking Sessions

Revoke a Specific Session

$user = User::find(1);
$sessionId = 123;

if ($user->revokeSession($sessionId)) {
    // Session revoked successfully
}

Revoke All Other Sessions

Keep the current device logged in while logging out all other devices:

$user = User::find(1);
$currentDeviceId = DeviceFingerprint::generate(request());

$revokedCount = $user->revokeAllOtherSessions($currentDeviceId);
// Returns the number of sessions revoked

Revoke All Sessions

Log out the user from all devices:

$user = User::find(1);

$revokedCount = $user->revokeAllSessions();
// Returns the number of sessions revoked

Checking Session Status

Check if a log entry represents an active session:

$log = AuthenticationLog::find(1);

if ($log->isActive()) {
    // Session is currently active
}

Example: Session Management UI

Here's an example of how you might display active sessions to users:

// In your controller
public function sessions()
{
    $user = auth()->user();
    $activeSessions = $user->getActiveSessions();
    
    return view('profile.sessions', compact('activeSessions'));
}

// In your view
[@foreach](https://github.com/foreach)($activeSessions as $session)
    <div class="session-item">
        <div>
            <strong>{{ $session->device_name ?? 'Unknown Device' }}</strong>
            [@if](https://github.com/if)($session->is_trusted)
                <span class="badge badge-success">Trusted</span>
            [@endif](https://github.com/endif)
        </div>
        <div>
            IP: {{ $session->ip_address }}
        </div>
        <div>
            Last Login: {{ $session->login_at->diffForHumans() }}
        </div>
        <div>
            <form action="{{ route('sessions.revoke', $session->id) }}" method="POST">
                [@csrf](https://github.com/csrf)
                [@method](https://github.com/method)('DELETE')
                <button type="submit">Revoke Session</button>
            </form>
        </div>
    </div>
[@endforeach](https://github.com/endforeach)

Example: Revoke Session Route

Route::post('/sessions/{session}/revoke', function ($sessionId) {
    $user = auth()->user();
    
    if ($user->revokeSession($sessionId)) {
        return redirect()->back()->with('success', 'Session revoked successfully');
    }
    
    return redirect()->back()->with('error', 'Failed to revoke session');
})->name('sessions.revoke');
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope