Isolated Sessions is a lightweight, zero-dependency PHP package that allows you to manage multiple, truly isolated session contexts in a single browser.
Login to multiple accounts simultaneously (e.g., Personal vs. Work) without incognito tabs or multiple browsers. Built-in encryption, CSRF protection, and a premium debug explorer included.
- 🛠 Multiple Contexts: Switch between
personal,work, or any custom context on the fly. - 🔒 AES-256-GCM Encryption: Industry-grade transparent encryption for session data.
- ⏱ Inactivity Expiration: Configurable per-context auto-logout.
- 🛡 Native CSRF Protection: Context-aware token generation and verification.
- 🧪 Premium Explorer: A stunning, Tailwind-styled UI for real-time debugging.
- ⚡️ Zero Dependencies: Pure PHP, compatible with any framework (Laravel, Symfony, WordPress).
composer require infinitietechnologies/isolated-sessionsuse Infinitietechnologies\IsolatedSessions\SessionManager;
use Infinitietechnologies\IsolatedSessions\Config\SessionConfig;
// Initialize with fluent config
$config = SessionConfig::create()
->withPrefix('MY_APP_')
->withInactivityTimeout(30);
$manager = new SessionManager($config);
// Auto-detect context from URL (?_context=) or Headers (X-Session-Context)
$session = $manager->autoDetectContext('default');
// Use it just like $_SESSION
$session['user_id'] = 123;
echo $session['user_id'];$personal = $manager->getSession('personal');
$personal['theme'] = 'light';
$work = $manager->getSession('work');
$work['theme'] = 'dark';By default, sessions are stored using standard PHP handlers. We recommend enabling encryption for production environments.
$config->withEncryption('your-32-byte-secret-key-goes-here');Each context generates its own unique CSRF tokens.
// In your controller
$token = $session->generateCsrfToken();
// On POST requests
if ($session->verifyCsrfToken($_POST['_token'])) {
// Valid request
}The Session Explorer is a professional UI component designed to help you visualize all active isolated sessions in real-time.
Important
For security, the Explorer is disabled by default. You must explicitly enable it for local development.
$config->withExplorer(true);
// At the bottom of your master layout/footer
---
## 📚 Examples & Demos
Check out the [examples/](examples/) directory for complete, ready-to-run scripts:
- [Basic Usage](examples/01-basic-usage.php)
- [Security Hardening](examples/02-security-hardened.php)
- [Web Explorer Demo](examples/web_explorer_demo.php)
- [CLI Test Suite](examples/cli_test.php)
---
## Author
- **Harshad** - [Infinitie Technologies](https://github.com/Infinitietechnologies)
---
## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.