Session Driver Configuration Analyzer
| Analyzer ID | Category | Severity | Time To Fix |
|---|---|---|---|
session-driver | ⚡ Performance | Critical | 30 minutes |
What This Checks
Validates that Laravel's session driver is appropriate for production scalability - Redis or database for multi-server setups, avoiding file-based sessions in load-balanced environments.
Why It Matters
- Scalability: File sessions only work on single servers
- Performance: Redis sessions are 10-100x faster than file/database
- User Experience: Lost sessions cause unexpected logouts
File-based sessions store data locally. In load-balanced environments, users may be routed to different servers where their session doesn't exist, causing unexpected logouts.
How to Fix
Quick Fix (5 minutes)
bash
# Set Redis as session driver
# .env
SESSION_DRIVER=redis
REDIS_HOST=127.0.0.1Proper Fix (30 minutes)
Install Redis:
bash
sudo apt-get install redis-server php-redis
php artisan session:table # If using databaseConfigure:
ini
SESSION_DRIVER=redis
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_CONNECTION=defaultShieldCI Configuration
This analyzer is automatically skipped in CI environments ($runInCI = false).
Why skip in CI?
- Session backends (Redis, database) may not be available or configured in CI pipelines
- CI environments typically use the
arrayorfilesession driver, which would trigger false warnings - Session driver choice is a deployment concern that doesn't need to be gated in CI
API-only / Stateless applications: This analyzer is also skipped for stateless applications — detected via middleware analysis. If your app has no session middleware registered, session driver checks do not apply.
When to run this analyzer:
- ✅ Local development: Confirms your session driver matches your production setup
- ✅ Staging/Production servers: Ensures a scalable driver (Redis, database) is configured for multi-server deployments
- ❌ CI/CD pipelines: Skipped automatically (session backends typically unavailable)
- ❌ API-only apps: Skipped automatically (no session middleware detected)
References
Related Analyzers
- Cache Driver Configuration Analyzer - Ensures a proper cache driver configuration for optimal performance
- Queue Driver Configuration Analyzer - Ensures a proper queue driver configuration for optimal performance and reliability