Download the PHP package stanleykinkelaar/laravel-browser-sessions-lite without Composer
On this page you can find all versions of the php package stanleykinkelaar/laravel-browser-sessions-lite. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stanleykinkelaar/laravel-browser-sessions-lite
More information about stanleykinkelaar/laravel-browser-sessions-lite
Files in stanleykinkelaar/laravel-browser-sessions-lite
Package laravel-browser-sessions-lite
Short Description A lightweight Laravel package for managing browser sessions with device detection and secure logout
License MIT
Homepage https://github.com/stanleykinkelaar/laravel-browser-sessions-lite
Informations about the package laravel-browser-sessions-lite
π Laravel Browser Sessions Lite
Ever wondered who's logged into your app right now? π€ This lightweight Laravel package lets users see all their active browser sessions and securely log out suspicious onesβall without the bloat of heavy device detection libraries.
Perfect for apps that need Jetstream-style session management but want to keep it simple and fast.
β¨ Features
- π± No Device Detection Libraries - Lightweight regex-based detection without heavy dependencies
- π Secure by Default - Password-verified logout prevents accidental lockouts
- π¨ Beautiful UI - Jetstream-inspired Blade view with Tailwind CSS
- π JSON API Ready - Full REST API support for SPAs and mobile apps
- π Smart Device Hints - Lightweight regex-based detection (iOS, Android, browsers, OS)
- β‘ Modern Laravel - Works seamlessly with Laravel 10, 11 & 12
- π§ͺ Battle-Tested - Comprehensive Pest test suite with 100% coverage
- π― Spatie Standards - Built on
spatie/laravel-package-tools
π― Use Cases
- Security-conscious apps - Let users monitor and manage their active sessions
- Multi-device workflows - Show users where they're logged in (phone, tablet, laptop)
- Account hijacking prevention - Users can quickly log out suspicious sessions
- Jetstream alternative - Get session management without Jetstream's full stack
π¦ Requirements
| Requirement | Version |
|---|---|
| PHP | 8.2+ |
| Laravel | 10.x, 11.x, 12.x |
| Session Driver | database |
π Installation
Step 1: Install via Composer
Step 2: Configure Database Sessions
This package requires Laravel's database session driver. Update your .env:
Create the sessions table (if you haven't already):
Step 3: Publish Assets (Optional)
Publish config file to customize routes and middleware:
Publish views to customize the UI:
βοΈ Configuration
The config file (config/browser-sessions-lite.php) allows you to customize behavior:
Pro tip: Need admin-only access? Change middleware to ['web', 'auth', 'admin']
π¨ Usage
Web UI (Blade)
The package automatically registers these routes:
| Method | URI | Description |
|---|---|---|
GET |
/user/browser-sessions |
View all sessions (Blade UI) |
DELETE |
/user/browser-sessions/others |
Logout other sessions |
Simply visit /user/browser-sessions in your browser to see the beautiful UI!
π That's it! The view looks like this:
- β List of all active sessions with device hints
- β Current device highlighted with a badge
- β IP addresses and "last active" timestamps
- β Password-protected "Log Out Other Sessions" button
- β Success/error flash messages
- β Fully responsive (mobile-friendly)
Programmatic Usage (PHP)
List Sessions for Current User
Logout Other Sessions (with password verification)
Force Logout (admin use - skips password check)
Check for Multiple Sessions
JSON API Usage (for SPAs & Mobile Apps)
All routes support JSON responses when using Accept: application/json header.
List Sessions (JSON)
Response:
Logout Other Sessions (JSON)
Success Response:
Error Response (422):
π Device Detection
The package uses simple regex patterns for device hints (no external libraries, zero bloat):
| User Agent Contains | Device Hint Shown |
|---|---|
iPhone, iPad, iPod |
iOS Device π± |
Android |
Android Device π€ |
Edg |
Edge Browser π |
Chrome |
Chrome Browser π |
Firefox |
Firefox Browser π¦ |
Safari |
Safari Browser π§ |
Windows |
Windows PC π» |
Macintosh, Mac OS |
Mac Computer π |
Linux |
Linux PC π§ |
Note: Detection order matters! Edge and Chrome are checked before Safari (since their UAs contain "Safari").
π¬ Example Integrations
Integration 1: Laravel Blade Layout
Integration 2: Vue/React SPA
Integration 3: Livewire Component
π€ Why No Device Detection Libraries?
This package intentionally avoids external device detection libraries like jenssegers/agent or mobiledetect/mobiledetectlib because:
β
Faster installation - No heavy dependencies to download
β
Fewer conflicts - Less chance of version mismatch issues
β
Smaller footprint - Keeps your vendor/ folder lean
β
Easier maintenance - Simple regex patterns anyone can understand
β
Focused purpose - Does one thing (session management) really well
Need advanced device detection? (browser versions, OS versions, device models, etc.) Consider using a dedicated package alongside this one. This package focuses on giving users just enough info to identify their devicesβwithout the bloat.
π§ͺ Testing
This package includes a comprehensive Pest test suite covering:
- β Repository layer (session queries, device detection)
- β Service layer (password verification, logout logic)
- β Controller layer (HTTP requests, JSON responses)
- β Integration tests (full flow from request to database)
Run Tests
Example Test Output
π οΈ How to Test in Your Package
Since this is a Spatie-style Laravel package, testing is set up using:
- Orchestra Testbench - Simulates a Laravel app environment
- Pest PHP - Modern testing framework
- In-memory SQLite - Fast test database
Running Tests During Development
Testing in a Real Laravel App
Want to test this package in your actual Laravel app before release?
Option 1: Composer Local Path
Add to your Laravel app's composer.json:
Then run:
Option 2: Testbench Workbench (Spatie Style)
Use Orchestra Testbench's workbench feature:
Visit http://localhost:8000/user/browser-sessions to test the UI!
π Architecture Overview
This package follows Spatie conventions and clean architecture:
Design principles:
- β Repository pattern - Separates database logic from business logic
- β Service layer - Handles password verification and authentication
- β Single responsibility - Each class does one thing well
- β Dependency injection - Fully testable and mockable
- β Laravel conventions - Feels native to Laravel
π Security Best Practices
This package is designed with security in mind:
β
Password verification required - Users must enter their password to log out other sessions
β
Laravel's current_password rule - Uses built-in validation
β
Auth middleware by default - Routes protected out of the box
β
CSRF protection - Form submissions are CSRF-protected
β
Session rehashing - Uses Laravel's Auth::logoutOtherDevices()
Reporting Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
π€ Contributing
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Write tests for your changes
- Run the test suite (
composer test) - Fix code style (
composer format) - Commit your changes (
git commit -m 'Add amazing feature') - Push to your branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please see CONTRIBUTING.md for detailed guidelines.
π Changelog
All notable changes are documented in CHANGELOG.md.
π License
The MIT License (MIT). See LICENSE.md for details.
π Credits
- Stanley Kinkelaar - Creator & Maintainer
- Inspired by Laravel Jetstream's session management
- Built on Spatie's Laravel Package Tools
- All contributors listed in contributors
β Show Your Support
If this package helped you, consider:
- β Starring the repo on GitHub
- π¦ Sharing it on Twitter
- β Buying me a coffee (coming soon!)
Made with β€οΈ by Stanley Kinkelaar
Built for the Laravel community π
All versions of laravel-browser-sessions-lite with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0|^11.0|^12.0