PHPackages                             mmdm/sim-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mmdm/sim-session

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mmdm/sim-session
================

A simple yet nice session management library

v1.1.2(5y ago)1391MITPHPPHP &gt;=7.2

Since Aug 2Pushed 5y agoCompare

[ Source](https://github.com/mmdm95/sim-session)[ Packagist](https://packagist.org/packages/mmdm/sim-session)[ RSS](/packages/mmdm-sim-session/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (6)Used By (1)

Simplicity Session
==================

[](#simplicity-session)

A library for session management.

Features
--------

[](#features)

- Simple sessions
- Time sessions
- Flash sessions
- Encrypted and secure
- Easy to use

Install
-------

[](#install)

**composer**

```
composer require mmdm/sim-session
```

Or you can simply download zip file from github and extract it, then put file to your project library and use it like other libraries.

Just add line below to autoload files:

```
require_once 'path_to_library/autoloader.php';
```

and you are good to go.

How to use
----------

[](#how-to-use)

```
// to instance a session object (without crypt)
$session = new Session();
// set a session
$session->set($key, $value);
// get a session
$theValue = $session->get($key);
```

Note: When you instantiate new session object, it will start session if it did not started yet.

Use with Crypt library
----------------------

[](#use-with-crypt-library)

If you need more security on sessions, use [Crypt](https://github.com/mmdm95/sim-crypt) library.

```
// send crypt instance through session
// constructure (dependency injection)
$session = new Session($crypt);
// now your sessions are safe
```

If you don't need some of your sessions to be secure, pass false as last parameter of set methods.

Available functions
-------------------

[](#available-functions)

- start(bool $regenerate = false, bool $delete\_old\_session = false)

This method starts session. To regenerate it, pass true as first argument.

**NOTE:** It checks if session is started yet, if not then start it.

```
// start PHP sessions
$session->start();
// regnerate session id
$session->start(true);
```

**NOTE:** By default it'll not delete previous session but you can make this happen by send boolean as second parameter.

- close()

This method close a started session.

```
// close PHP session
$session->close();
```

- hasStart(): bool

This method check if PHP session has started.

```
// close PHP session
$session->hasStart();
```

- set(string $key, $value, bool $encrypt = true): ISession

This method set $key to session with $value. To prevent encrypting when Crypt is specified through construct method, pass false as last parameter to not encrypt $value.

Note: To store multidimensional array in session, $key can be dotted separated strings.

exp. foo.bar =&gt; $\_SESSION\['foo'\]\['bar'\].

```
// to set a session
$session->set('foo', 'I am a normal session');
// or
$session->set('foo.bar', 'I am a normal session');
```

- get(string $key = null, $prefer = null): mixed

This method get value of $key from session. If there is no session with key of $key it will return $prefer instead that can be specified through second argument - default is NULL.

Note: To get multidimensional array from session, $key can be dotted separated strings.

exp. foo.bar =&gt; $\_SESSION\['foo'\]\['bar'\].

```
// to get a session
$session->get('foo');
// or
$session->get('foo.bar', 'not set');
```

- remove(string $key): ISession

This method removes value of $key from session.

Note: To remove multidimensional array from session, $key can be dotted separated strings.

exp. foo.bar =&gt; $\_SESSION\['foo'\]\['bar'\].

```
// to remove a session
$session->remove('foo');
// or
$session->remove('foo.bar');
```

- has(string $key): bool

This method checks if $key is exists in sessions.

Note: To check multidimensional array in session, $key can be dotted separated strings.

exp. foo.bar =&gt; $\_SESSION\['foo'\]\['bar'\].

```
// to check existence of a session
$session->has('foo');
// or
$session->has('foo.bar');
```

- setTimed(string $key, $value, $time = 300, bool $encrypt = true): ISession

This method is like simple set method, the only difference is $time. With this feature you can define timer for a session value. Default value is 300 seconds.

```
// to set a timer session
$session->setTimed('foo', 'I will expire after 10 seconds', 10);
// or
$session->setTimed('foo.bar');
```

- getTimed(string $key = null, $prefer = null): mixed

This method is like simple get method.

```
// to set a timer session
$session->getTimed('foo');
// or
$session->getTimed('foo.bar', 'not set');
```

- removeTimed(?string $key): ISession

This method is like simple remove method. The only difference is you can pass NULL to remove all timer sessions

```
// to remove a timer session
$session->removeTimed('foo');
// or
$session->removeTimed('foo.bar');
```

- hasTimed(string $key): bool

This method is like simple has method.

```
// to check existence of a timer session
$session->hasTimed('foo');
// or
$session->hasTimed('foo.bar');
```

- setFlash(string $key, $value, bool $encrypt = true): ISession

This method is like simple set method.

```
// to set a flash session
$session->setFlash('foo');
// or
$session->setFlash('foo.bar');
```

- getFlash(string $key = null, $prefer = null, $delete = true): mixed

This method is like simple get method. The only difference is after get a flash session, default behavior is to remove that session, but you can make it not to remove through last parameter.

```
// to get a flash session
$session->getFlash('foo');
// or
$session->getFlash('foo.bar', 'not set');
```

- removeFlash(?string $key = null): ISession

This method is like simple remove method. The only difference is you can pass NULL to remove all timer sessions

```
// to remove a flash session
$session->removeFlash('foo');
// or
$session->removeFlash('foo.bar', 'not set');
```

- hasFlash(string $key): bool

This method is like simple has method.

```
// to check existence of a flash session
$session->hasFlash('foo');
// or
$session->hasFlash('foo.bar');
```

Dependencies
============

[](#dependencies)

There is just one dependency and it is [Crypt](https://github.com/mmdm95/sim-crypt) library. With this feature, if any session hijacking happens, they can't see actual data because it is encrypted.

License
=======

[](#license)

Under MIT license.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

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

Total

5

Last Release

1917d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d955ebaae3fe602e6ad26c16422f6ab25a61a436fd7f08425a5be5c73ef9025c?d=identicon)[mmdm95](/maintainers/mmdm95)

---

Top Contributors

[![mmdm95](https://avatars.githubusercontent.com/u/26489185?v=4)](https://github.com/mmdm95 "mmdm95 (21 commits)")

### Embed Badge

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

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

###  Alternatives

[sixty-nine/php-cloud-lib

A library to generate words clouds in PHP

2012.4k](/packages/sixty-nine-php-cloud-lib)

PHPackages © 2026

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