Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akrabat/rka-slim-session-middleware
Simple session middleware for Slim Framework
https://github.com/akrabat/rka-slim-session-middleware
Last synced: 28 days ago
JSON representation
Simple session middleware for Slim Framework
- Host: GitHub
- URL: https://github.com/akrabat/rka-slim-session-middleware
- Owner: akrabat
- License: other
- Created: 2015-01-07T09:28:55.000Z (about 10 years ago)
- Default Branch: main
- Last Pushed: 2023-05-31T06:53:12.000Z (over 1 year ago)
- Last Synced: 2024-12-19T03:09:50.898Z (about 1 month ago)
- Language: PHP
- Size: 62.5 KB
- Stars: 43
- Watchers: 6
- Forks: 13
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RKA Slim Session Middleware
Middleware for [Slim Framework][1] 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();
[1]: https://www.slimframework.com/