PHPackages                             natilosir/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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. natilosir/session

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

natilosir/session
=================

A simple library for creating and managing sessions in PHP

1.0.1(1y ago)141MITPHP

Since Jan 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/natilosir/Session-PHP)[ Packagist](https://packagist.org/packages/natilosir/session)[ RSS](/packages/natilosir-session/feed)WikiDiscussions main Synced today

READMEChangelog (1)DependenciesVersions (3)Used By (1)

sessions-PHP
============

[](#sessions-php)

A simple library for creating and managing sessions in PHP

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

[](#installation)

You can install this package via Composer:

```
composer require natilosir/Session
```

Overview
--------

[](#overview)

The `Session` class provides a simple and effective way to manage session variables in PHP. It includes methods for setting, getting, deleting, clearing, and listing session variables, as well as destroying the entire session.

Features
--------

[](#features)

- Set session variables
- Get session variables
- Delete individual session variables
- Clear all session variables
- Destroy the session
- List all session variables

Usage
-----

[](#usage)

### Setting a Session Variable

[](#setting-a-session-variable)

To set a session variable, use the `set` method:

```
Session::set('username', 'John Doe');
```

### Getting a Session Variable

[](#getting-a-session-variable)

To retrieve a session variable, use the get method:

```
$username = Session::get('username');
echo 'Username: ' . $username; // Outputs: Username: John Doe
```

### Deleting a Session Variable

[](#deleting-a-session-variable)

To delete a specific session variable, use the delete method:

```
Session::delete('username');
```

### Clearing All Session Variables

[](#clearing-all-session-variables)

To clear all session variables, you can use the clear method:

```
Session::set('user_id', 1);
Session::clear(); // Clears all session variables
```

### Destroying the Session

[](#destroying-the-session)

To destroy the entire session, use the destroy method:

```
Session::destroy();
```

Listing All Session Variables To list all session variables currently set, use the list method:

```
$all = Session::list();
print_r($all); // Outputs all session variables
```

Example Code Here’s a complete example demonstrating the usage of the Session class:

```
// Set a session variable
Session::set('username', 'John Doe');

// Get the session variable
$username = Session::get('username');
echo 'Username: ' . $username; // Outputs: Username: John Doe

// Delete the session variable
Session::delete('username');

// Clear all session variables
Session::clear(); // Clears all session variables

// Check if all session variables are cleared
$userId = Session::get('user_id');
echo 'User ID after clearing: ' . ($userId ?? 'Not set'); // Outputs: User ID after clearing: Not set

// Destroy the session
Session::destroy();

// List all session variables
$all = Session::list();
print_r($all); // Outputs all session variables
```

Conclusion
----------

[](#conclusion)

The Session class simplifies session management in PHP applications, providing a clean and intuitive interface for working with session variables. Feel free to contribute to this project by submitting issues or pull requests!

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

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 ~0 days

Total

2

Last Release

527d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/182812192?v=4)[MMD](/maintainers/natilosir)[@natilosir](https://github.com/natilosir)

### Embed Badge

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

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

###  Alternatives

[vitalybaev/laravel5-dkim

Laravel 5/6 package for signing outgoing messages with DKIM.

3163.1k](/packages/vitalybaev-laravel5-dkim)

PHPackages © 2026

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