Download the PHP package abollinger/session without Composer
On this page you can find all versions of the php package abollinger/session. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download abollinger/session
More information about abollinger/session
Files in abollinger/session
Package session
Short Description PHP Session management for the partez framework
License MIT
Informations about the package session
Abollinger\Session
Abollinger\Session is a PHP library designed to manage user session-related functionalities. It offers an easy-to-use interface for session management, user authentication, login, and logout processes, leveraging PHP's native session handling mechanisms and SQLite for token storage.
Features
-
Session Management: Automatically initializes a session if not already active.
-
User Authentication: Supports authentication checks with token validation, including cross-server requests.
-
Login and Logout: Provides methods to securely log in and log out users, managing session variables and database records.
- Error Handling: Logs errors for debugging and ensures secure exception handling.
Requirements
- PHP 7.4 or higher
- SQLite3 extension enabled
Installation
You can install the Abollinger\Session package using Composer. Run the following command:
Then, include the Composer autoloader in your project:
Usage
Initialization
Login
Authentication Check
Logout
API Reference
Constructor
__construct()
Initializes a session if none exists and sets up the SQLite connection.
Methods
isLoggedAndAuthorized(bool $isSameServer = false): bool
Description: Checks if a user is logged in and authorized.
-
Parameters:
-
$isSameServer (bool)
: Defaults to false. Determines whether to validate via session variables or headers. - Returns:
true
if the user is authenticated; otherwisefalse
.
-
login(array $arr): void
Description: Logs in a user by setting session variables and saving the token to the database.
- Parameters:
$arr
(array): ContainsuserId
andtoken
.
logout(array $arr): void
Description: Logs out a user by removing session variables, deleting the token from the database, and destroying the session.
- Parameters:
$arr
(array): ContainsuserId
.
Example Workflow
-
Start a session:
-
Log in a user:
-
Verify user authentication:
- Log out the user:
Licence
This library is licensed under the MIT License. For full license details, see the LICENCE
file distributed with this source code.
Author
Antoine Bollinger Email: [email protected]
For contributions, issues, or feedback, feel free to contact the author or open a GitHub issue.