Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sroehrl/neoan3-session
https://github.com/sroehrl/neoan3-session
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/sroehrl/neoan3-session
- Owner: sroehrl
- License: mit
- Created: 2018-12-09T17:07:35.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-13T17:32:29.000Z (about 4 years ago)
- Last Synced: 2024-04-30T16:10:45.219Z (7 months ago)
- Language: PHP
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# neoan3 basic session handling
This class handles basic PHP-session requirements and is designed to play nicely with a neoan3 setup.
[![Maintainability](https://api.codeclimate.com/v1/badges/e2f2aafd0ca17882fed8/maintainability)](https://codeclimate.com/github/sroehrl/neoan3-session/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/e2f2aafd0ca17882fed8/test_coverage)](https://codeclimate.com/github/sroehrl/neoan3-session/test_coverage)
[![Build Status](https://travis-ci.com/sroehrl/neoan3-session.svg?branch=master)](https://travis-ci.com/sroehrl/neoan3-session)## 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
```PHP
[
'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 arrayand 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.