Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Isolated Sessions for PHP 🚀

Latest Version on Packagist Total Downloads PHP Version License

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.


Key Features

  • 🛠 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).

Installation

composer require infinitietechnologies/isolated-sessions

Quick Start

1. Basic Setup

use 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'];

2. Manual Context Switching

$personal = $manager->getSession('personal');
$personal['theme'] = 'light';

$work = $manager->getSession('work');
$work['theme'] = 'dark';

Security Guide

Session Hardening

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');

CSRF Protection

Each context generates its own unique CSRF tokens.

// In your controller
$token = $session->generateCsrfToken();

// On POST requests
if ($session->verifyCsrfToken($_POST['_token'])) {
    // Valid request
}

Debugging with Session Explorer

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.

About

a lightweight, zero-dependency PHP package for truly isolated sessions.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages