custom-d/redis-session

Redis Session reader from laravel for legacy projects

v1.0.2 2023-10-30 01:36 UTC

This package is auto-updated.

Last update: 2024-11-13 14:36:32 UTC


README

[![Latest Version on Packagist](https://img.shields.io/packagist/v/custom d/redis-session.svg?style=flat-square)](https://packagist.org/packages/custom d/redis-session) [![Total Downloads](https://img.shields.io/packagist/dt/custom d/redis-session.svg?style=flat-square)](https://packagist.org/packages/custom d/redis-session) ![GitHub Actions](https://github.com/custom d/redis-session/actions/workflows/main.yml/badge.svg)

This package allows you to read the laravel session cookie and parse the session data from laravel into your legacy app aswell as write session data to the session

Installation

You can install the package via composer:

composer require custom d/redis-session

Usage

\CustomD\RedisSession\RedisSession::init(\CustomD\RedisSession\RedisSession::init(
    [
        'encryption_key'    => env('SHARED_ENCRYPTION_KEY'),
        'encryption_cypher' => env('SHARED_ENCRYPTION_CYPHER', 'AES-256-CBC'),
        'redis'             => [
            'client'  => env('REDIS_CLIENT', 'phpredis'),
            'options' => [
                'cluster' => env('REDIS_CLUSTER', 'redis'),
                'prefix'  =>  env('REDIS_PREFIX', 'laravel_database_laravel_cache_:'),
            ],
            'default' => [
                'host'     => env('REDIS_HOST', 'cache'),
                'port'     => env('REDIS_PORT', '6379'),
                'username' => env('REDIS_USERNAME'),
                'password' => env('REDIS_PASSWORD'),
                'database' => env('REDIS_DATABASE'),
            ]
    
        ],
        'session'           => [
            'lifetime'        => env('SESSION_LIFETIME', 120),
            'expire_on_close' => env('SESSION_EXPIRE_ON_CLOSE', false),
            'encrypt'         => env('SESSION_ENCRYPT', false),
            'cookie'          => env('SESSION_COOKIE', 'laravel_session'),
            'path'            => env('SESSION_PATH', '/'),
            'domain'          => env('SESSION_DOMAIN'),
            'secure'          => env('SESSION_SECURE'),
            'http_only'       => env('SESSION_HTTP_ONLY', true),
        ],
    ]
));


    // Retrieve a piece of data from the session...
    $value = session('key');
 
    // Specifying a default value...
    $value = session('key', 'default');
 
    // Store a piece of data in the session...
    session(['key' => 'value']);

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email craig.smith@customd.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.