PHPackages                             dzentota/session - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. dzentota/session

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

dzentota/session
================

Secure session management library with a focus on security and type safety

09PHP

Since Jul 17Pushed 10mo agoCompare

[ Source](https://github.com/dzentota/session)[ Packagist](https://packagist.org/packages/dzentota/session)[ RSS](/packages/dzentota-session/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Secure Session Library
==========================

[](#php-secure-session-library)

A secure and flexible session management library for PHP applications with PSR-7, PSR-15, and PSR-16 support.

Features
--------

[](#features)

- 🔒 **Complete Security**: CSRF protection, data encryption, session hijacking prevention
- 🧱 **Modular Architecture**: Flexible choice of session storage (cache, database)
- 🚀 **High Performance**: Optimized session lifetime management
- 🔌 **PSR Compatibility**: Integration with any PSR-7/PSR-15 framework
- 🧪 **Full Test Coverage**: Reliability and stability guaranteed

Installation
------------

[](#installation)

```
composer require dzentota/session
```

Quick Start
-----------

[](#quick-start)

### Basic Usage

[](#basic-usage)

```
use Dzentota\Session\SessionManager;
use Dzentota\Session\Cookie\CookieManager;
use Dzentota\Session\Storage\CacheStorage;
use Psr\SimpleCache\CacheInterface;

// Initialize dependencies
$cache = new YourPsrCacheImplementation();
$storage = new CacheStorage($cache);
$cookieManager = new CookieManager('session', '/', 3600, true, true, 'Lax');

// Create session manager
$sessionManager = new SessionManager($storage, $cookieManager);

// Work with session data
$sessionManager->start($request);
$sessionManager->set('user_id', 123);
$userId = $sessionManager->get('user_id');

// Add CSRF protection
$token = $sessionManager->generateCsrfToken();
// Insert the token into your application forms:
//
