PHPackages                             abollinger/session - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. abollinger/session

ActiveLibrary[Framework](/categories/framework)

abollinger/session
==================

PHP Session management for the partez framework

v1.2.1(1y ago)03061MITPHP

Since Mar 12Pushed 1y agoCompare

[ Source](https://github.com/Antoine-Bollinger/session)[ Packagist](https://packagist.org/packages/abollinger/session)[ RSS](/packages/abollinger-session/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (20)Used By (1)

Abollinger\\Session
===================

[](#abollingersession)

**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
--------

[](#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
------------

[](#requirements)

- PHP 7.4 or higher
- SQLite3 extension enabled

Installation
------------

[](#installation)

You can install the **Abollinger\\Session** package using Composer. Run the following command:

```
composer require abollinger/session
```

Then, include the Composer autoloader in your project:

```
require_once 'vendor/autoload.php';
use Abollinger\Session;
```

Usage
-----

[](#usage)

### Initialization

[](#initialization)

```
use Abollinger\Session;

// Instantiate the session manager
$session = new Session();
```

### Login

[](#login)

```
$session->login([
    "userId" => "exampleUser123",
    "token"  => "secureToken123"
]);
```

### Authentication Check

[](#authentication-check)

```
$isAuthenticated = $session->isLoggedAndAuthorized($isSameServer = true);

if ($isAuthenticated) {
    echo "User is authenticated!";
} else {
    echo "Authentication failed.";
}
```

### Logout

[](#logout)

```
$session->logout([
    "userId" => "exampleUser123"
]);
```

API Reference
-------------

[](#api-reference)

### Constructor

[](#constructor)

`__construct()`Initializes a session if none exists and sets up the SQLite connection.

### Methods

[](#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; otherwise `false`.

`login(array $arr): void`

Description: Logs in a user by setting session variables and saving the token to the database.

- Parameters:
    - `$arr` (array): Contains `userId` and `token`.

`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): Contains `userId`.

Example Workflow
----------------

[](#example-workflow)

1. Start a session:

```
$session = new Session();
```

2. Log in a user:

```
$session->login([
    "userId" => "exampleUser",
    "token"  => "exampleToken"
]);
```

3. Verify user authentication:

```
if ($session->isLoggedAndAuthorized()) {
    echo "User is authenticated!";
} else {
    echo "Authentication failed.";
}
```

4. Log out the user:

```
$session->logout([
    "userId" => "exampleUser"
]);
```

Licence
-------

[](#licence)

This library is licensed under the MIT License. For full license details, see the `LICENCE` file distributed with this source code.

Author
------

[](#author)

Antoine Bollinger Email:

For contributions, issues, or feedback, feel free to contact the author or open a GitHub issue.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~15 days

Total

19

Last Release

531d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4ef76077f29bfc3b32b0b1d21d2f4122af8109f23aa48586ea68d768e01f354f?d=identicon)[antoinebollinger](/maintainers/antoinebollinger)

---

Top Contributors

[![antoinebollinger](https://avatars.githubusercontent.com/u/56133015?v=4)](https://github.com/antoinebollinger "antoinebollinger (19 commits)")

### Embed Badge

![Health badge](/badges/abollinger-session/health.svg)

```
[![Health](https://phpackages.com/badges/abollinger-session/health.svg)](https://phpackages.com/packages/abollinger-session)
```

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
