neoan3-apps / session
neoan3 session class
Requires
- ext-json: *
Requires (Dev)
- phpunit/phpunit: 9.4.1
This package is auto-updated.
Last update: 2024-12-14 02:12:51 UTC
README
This class handles basic PHP-session requirements and is designed to play nicely with a neoan3 setup.
Installation
composer require neoan3-apps/session
Implementation
Create a new Session as early as possible in your code with:
new \Neoan3\Apps\Session();
Also check out playground for an OOP example.
Usage
Session::login($userId [,$scope=[], $payload =[]])
Registers a user with the following template
[ 'user' => ['id' => $userId, 'user_type' => 'user'], 'scope' => $scope, 'payload' => $payload ];
Session::logout()
Terminates all session variables
Session::addToSession($array)
Adds multiple variables to payload using an associative array.
Session::restrict($array||null)
Checks if user is logged in and (if parameter is set) whether the user belongs to
- ONE OF the roles in the given array
and throws an exception is the condition is not met
NOTE:
This repo has an OOP version satisfying "neoan3-provider/auth". If you want to use sessions in your neoan3 project, simply use Auth's SessionWrapper.