GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - flightphp/session: Tidy session library for Flight PHP

BranchesTags
Open more actions menu

Latest commit

 

History

10 Commits
10 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
composer.json
composer.json
 
 
phpcs.xml
phpcs.xml
 
 
phpunit.xml
phpunit.xml
 
 

Repository files navigation

FlightPHP Session

Latest Stable Version License PHP Version Require Dependencies

A lightweight, file-based session handler for the Flight framework. It supports non-blocking behavior, optional encryption, and auto-commit functionality. See basic example.

Installation

Simply install with Composer

composer require flightphp/session

Basic Example

Let's see how easy it is to use FlightPHP Session:

// Create a session instance with default settings
$session = new flight\Session();

// Store some data
$session->set('user_id', 123);
$session->set('username', 'johndoe');
$session->set('is_admin', false);

// Retrieve data
echo $session->get('username'); // Outputs: johndoe

// Use a default value if the key doesn't exist
echo $session->get('preferences', 'default_theme'); // Outputs: default_theme

// Remove a session value
$session->delete('is_admin');

// Check if a value exists
if ($session->get('user_id')) {
    echo 'User is logged in!';
}

// Clear all session data
$session->clear();

Advanced Configuration

You can customize the session handler with various configuration options:

$session = new flight\Session([
    'save_path' => '/custom/path/to/sessions', // Custom directory for storing session files
    'encryption_key' => 'your-secret-32-byte-key', // Enable encryption with a secure key
    'auto_commit' => true, // Automatically commit session changes on shutdown
    'start_session' => true, // Start the session automatically
    'test_mode' => false, // Enable for testing without affecting PHP's session state
]);

Session Security

When dealing with sensitive user data, it's recommended to use encryption:

// Create a session with encryption enabled
$session = new flight\Session([
    'encryption_key' => 'a-secure-32-byte-key-for-aes-256-cbc',
]);

// Now all session data will be automatically encrypted when stored
$session->set('credit_card', '4111-1111-1111-1111');

Session Regeneration

For security purposes, you might want to regenerate the session ID periodically:

// Regenerate the session ID and keep the current session data
$session->regenerate();

// Regenerate the session ID and delete the old session data
$session->regenerate(true);

Documentation

Head over to the documentation page to learn more about usage and how cool this thing is! :)

License

MIT

About

Tidy session library for Flight PHP

docs.flightphp.com/awesome-plugins/session

Topics

flightphpphpsessionsession-management

Resources

Readme
MIT license
Activity
Custom properties

Stars

11 stars

Watchers

2 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.