An open API service indexing awesome lists of open source software.

https://github.com/pardnio/php-session-fallback

(PHP Library) Session manager with graceful fallback
https://github.com/pardnio/php-session-fallback

backend pardnchiu php session

Last synced: about 1 month ago
JSON representation

(PHP Library) Session manager with graceful fallback

Awesome Lists containing this project

README

          

# PD\Session

> PD\Session is a flexible PHP session manager with Redis support and filesystem fallback. Provides secure session handling.

![tag](https://img.shields.io/badge/tag-PHP%20Library-bb4444)
![size](https://img.shields.io/github/size/pardnchiu/PHP-Session/src/Session.php)

![version](https://img.shields.io/packagist/v/pardnchiu/session)
![download](https://img.shields.io/packagist/dm/pardnchiu/session)

## Features

- Dual storage support (Redis / Filesystem)
- Automatic fallback mechanism
- Session security enhancements
- Built-in session lifetime management
- Session ID regeneration
- Creation time tracking

## Security Features

- 7-day session lifetime
- Automatic garbage collection
- Session ID regeneration support
- Secure storage handling
- System resilience fallback mechanism

## Dependencies

- `pardnchiu/redis` - For Redis caching support (optional)
- `/storage/sessions` - Write permission required for storage directory

## How to Use

### Installation

```shell
composer require pardnchiu/session
```

```php
// Initialize with Redis support
$redis = new PD\Redis();
$session = new PD\Session($redis);

// Basic session operations
$session->set("user_id", 123);
$userId = $session->get("user_id");
$session->delete("user_id");

// Security operations
$session->regenerateId(); // Regenerate session ID
$session->destroy(); // Destroy session

// Session information
$sessionId = $session->getId();
$createdTime = $session->getCreatedTime();

// Initialize without Redis (filesystem only)
$session = new PD\Session();
```

## License

This source code project is licensed under the [MIT](https://github.com/pardnchiu/PHP-Session/blob/main/LICENSE) license.

## Creator

#### Pardn Chiu






---

©️ 2024 [Pardn Chiu](https://pardn.io)