PHPackages                             openlss/lib-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. openlss/lib-session

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

openlss/lib-session
===================

Abstract library for handling account sessions and cookies

0.0.10(13y ago)1120LGPL-3.0+PHPPHP &gt;=5.3.2

Since Mar 24Pushed 13y ago1 watchersCompare

[ Source](https://github.com/nullivex/lib-session)[ Packagist](https://packagist.org/packages/openlss/lib-session)[ Docs](http://openlss.org)[ RSS](/packages/openlss-lib-session/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (7)Versions (12)Used By (0)

openlss/lib-session
===================

[](#openlsslib-session)

Abstract library for handling account sessions and cookies

Usage
-----

[](#usage)

```
//extending

abstract class StaffSession extends \LSS\Session {
	public static function requireManager(){
		if(self::get('is_manager')) return true;
		throw new Exception('Permission denied');
	}

	public static function init(){
		self::$config_name		= 'staff';
		self::$session_name		= 'staff_token';
		self::$session_table	= 'staff_session';
		self::$user_primary_key	= 'staff_id';
	}
}

//overrides the parent vars
StaffSession::init();

//check for session
try {
	if(StaffSession::checkLogin()){
		//register session
		$token = StaffSession::fetchByToken(StaffSession::getTokenFromSession());
		$session = array_merge(Staff::fetch($token['staff_id']),$token);
		StaffSession::storeSession($session);
		unset($session,$token);
		//set tpl globals (if Tpl is available)
		if(is_callable(array('Tpl','_get'))){
			Tpl::_get()->set(array(
				 'staff_name'		=>	StaffSession::get('name')
				,'staff_lastlogin'	=>	date(Config::get('account.date.general_format'),StaffSession::get('last_login'))
			));
		}
	} else {
		if(server('REQUEST_URI') != Url::login()) redirect(Url::login());
	}
} catch(Exception $e){
	StaffSession::tokenDestroy(StaffSession::getTokenFromSession());
	StaffSession::destroySession();
	redirect(Url::login());
}
```

Reference
---------

[](#reference)

### (bool) Session::isLoggedIn()

[](#bool-sessionisloggedin)

Returns true when a valid session exists

### (bool) Session::requireLogin()

[](#bool-sessionrequirelogin)

Redirects to Url::login() if no session is found

### (bool) Session::checkLogin()

[](#bool-sessionchecklogin)

Checks if a session needed to validate a login exists

### (bool) Session::get($var=false)

[](#bool-sessiongetvarfalse)

Returns MDA key from the session registry When $var is FALSE the entire registry is returned

```
$staff_id = Session::get('staff_id');
```

### (bool) Session::storeSession($session)

[](#bool-sessionstoresessionsession)

Sets the session registry Returns TRUE on success FALSE on failure

### (string) Session::getTokenFromSession()

[](#string-sessiongettokenfromsession)

Returns the current session token

### (void) Session::startSession($token)

[](#void-sessionstartsessiontoken)

Stores the token in an actual PHP session

### (void) Session::destroySession()

[](#void-sessiondestroysession)

Destroys the session help in PHP

### (array) Session::fetchByToken($token)

[](#array-sessionfetchbytokentoken)

Return a session by token

### (array) Session::findToken($id,$remote\_ip,$user\_agent)

[](#array-sessionfindtokenidremote_ipuser_agent)

- $id The identifier of the account
- $remote\_ip Remote IP address used for session
- $user\_agent The USER\_AGENT field of the remote user Returns a session record

### (mixed) Session::tokenCheck($token,$remote\_ip,$return\_token=false)

[](#mixed-sessiontokenchecktokenremote_ipreturn_tokenfalse)

- $token The session token
- $remote\_ip Remote IP of the session starter
- $return\_token When FALSE this function returns BOOL otherwise returns the token

### (string) Session::tokenCreate($id,$remote\_ip,$user\_agent)

[](#string-sessiontokencreateidremote_ipuser_agent)

- $id The identifier of the account
- $remote\_ip Remote IP address used for session
- $user\_agent The USER\_AGENT field of the remote user Returns the newly created token

### (string) Session::tokenDestroy($token)

[](#string-sessiontokendestroytoken)

Destroys the given token and returns that token

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 84.6% 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 ~2 days

Total

10

Last Release

4822d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/83c8e9d55e3ebafb0621a441a51af8f551f61a274fde5400459a29cc320b7b75?d=identicon)[nullivex](/maintainers/nullivex)

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

---

Top Contributors

[![nullivex](https://avatars.githubusercontent.com/u/2321375?v=4)](https://github.com/nullivex "nullivex (22 commits)")[![Spudz76](https://avatars.githubusercontent.com/u/2391234?v=4)](https://github.com/Spudz76 "Spudz76 (4 commits)")

---

Tags

Authenticationcookiessessions

### Embed Badge

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

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

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k50.9M364](/packages/tymon-jwt-auth)[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.7k143.0M274](/packages/league-oauth2-server)[league/oauth2-client

OAuth 2.0 Client Library

3.8k125.2M1.3k](/packages/league-oauth2-client)[google/auth

Google Auth Library for PHP

1.4k286.7M205](/packages/google-auth)[pragmarx/google2fa

A One Time Password Authentication package, compatible with Google Authenticator.

2.0k92.3M225](/packages/pragmarx-google2fa)[paragonie/sodium_compat

Pure PHP implementation of libsodium; uses the PHP extension if it exists

931141.1M172](/packages/paragonie-sodium-compat)

PHPackages © 2026

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