Skip to content
Simple session middleware for Slim Framework
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
RKA
tests Add PHPCS and fix issues. Apr 18, 2016
.gitignore
LICENSE
README.md
composer.json
composer.lock
phpcs.xml
phpunit.xml Move phpunit.xml to top level directory Apr 18, 2016

README.md

RKA Slim Session Middleware

Middleware for Slim Framework that starts a session. Also provides a useful Session class.

Installation

composer require "akrabat/rka-slim-session-middleware"

Usage

Add middleware as usual:

$app->add(new \RKA\SessionMiddleware(['name' => 'MySessionName']));

RKA\Session

You can use \RKA\Session to access session variables. The main thing that this gives you is defaults and an OO interface:

$app->get('/', function ($request, $response) {
    $session = new \RKA\Session();

    // Get session variable:
    $foo = $session->get('foo', 'some-default');
    $bar = $session->bar;

    // Set session variable:
    $session->foo = 'this';
    $session->set('bar', 'that');

    return $response;
});

if you need to destroy the session, you can do:

\RKA\Session::destroy();
You can’t perform that action at this time.