neoan3-apps/session

There is no license information available for the latest version (1.0.0) of this package.

neoan3 session class

1.0.0 2020-10-13 17:28 UTC

This package is auto-updated.

Last update: 2024-07-14 01:22:54 UTC


README

This class handles basic PHP-session requirements and is designed to play nicely with a neoan3 setup.

Maintainability Test Coverage Build Status

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.