Download the PHP package inanepain/session without Composer

On this page you can find all versions of the php package inanepain/session. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package session

= inanepain/session image:./icon.png[title=inanepain/session,25] :author: Philip Michael Raab :email: [email protected] :description: A lightweight, secure and extensible PHP session handling library. :keywords: inanepain, library, session, secure, remember me :homepage: https://github.com/inanepain/session :revnumber: 0.1.0 :revdate: 2025-11-10 :copyright: Unlicense :experimental: :hide-uri-scheme: :icons: font :source-highlighter: highlight.js :toc: left :toclevels: 3 :sectanchors: :idprefix: topic- :idseparator: - :pkg-vendor: inanepain :pkg-name: session :pkg-id: {pkg-vendor}/{pkg-name}

== image:./icon.png[title={pkg-id},25] {pkg-id}

{description}

:sectnums:

<<<

:leveloffset: +1

= Introduction

SessionManager is a lightweight, secure, and extensible PHP session handling library designed for modern web applications. It provides a simple static API for managing sessions with built-in security features like HTTP-only cookies, SameSite protection, periodic ID regeneration, and inactivity timeouts. It supports namespacing to avoid key collisions and "remember me" functionality for persistent sessions across browser closes.

Key features:

This library is dependency-free, PSR-compliant, and production-ready.

== Why SessionManager? Native PHP sessions are powerful but lack secure defaults and organization. SessionManager wraps session_* functions with best practices, preventing common pitfalls like fixation attacks and key conflicts.

:leveloffset!:

<<<

:leveloffset: +1

= Install

.composer [source,shell,subs=attributes+]

composer require {pkg-id}

:leveloffset!:

<<<

:leveloffset: +1

= Quick Start

== Basic Usage Require the file and initialize:

[source,php]

SessionManager::init([ 'name' => 'MYAPP_SESSID', // 'cookie_secure' => true, // HTTPS only 'cookie_samesite' => 'Strict', ]);

// Set and get data SessionManager::set('user_id', 123); echo SessionManager::get('user_id'); // 123

// Flash message SessionManager::flash('success', 'Login successful!'); header('Location: /dashboard'); exit;

// In dashboard.php if (SessionManager::hasFlash('success')) { echo SessionManager::getFlash('success'); }

// Logout SessionManager::destroy();

== Namespaced Sessions Use the base class SessionNamespace for modular access:

[source,php]

class UserSession extends SessionNamespace { protected const NAMESPACE = 'user'; }

class CartSession extends SessionNamespace { protected const NAMESPACE = 'cart'; }

// Usage UserSession::set('id', 456); CartSession::set('items', ['item1']); echo UserSession::get('id'); // 456

:leveloffset!:

<<<

:leveloffset: +1

= Configuration

Pass options to init() to customize behaviour. Defaults are secure.

[options="header"] |=== | Option | Type | Default | Description | cookie_lifetime | int | 0 | Cookie expiry (0 = browser close; >0 for persistent). | cookie_path | string | / | Cookie path. | cookie_domain | string | '' | Cookie domain. | cookie_secure | bool | HTTPS detected | HTTPS-only cookie. | cookie_httponly | bool | true | Prevent JS access. | cookie_samesite | string | Lax | CSRF protection (Lax/Strict/None). | use_strict_mode | bool | true | Reject uninit sessions. | use_only_cookies | bool | true | No URL param fallback. | name | string | PHPSESSID | Session cookie name. | gc_maxlifetime | int | 1440 | Garbage collection (minutes). | memory_limit | string | null | Temp boost (e.g., '2G'; dev only). | max_session_size | int | 104857600 | Clear if >100MB (bytes). | force_clear | bool | false | Nuke session on init (dev). | remember_me | bool | false | Auto-set lifetime to 30 days. |===

Example with persistent session: [source,php]

SessionManager::init([ 'remember_me' => true, // 30-day cookie // 'cookie_secure' => true, ]);

Runtime toggles: [source,php]

SessionManager::enableRememberMe(86400 * 7); // 1 week SessionManager::disableRememberMe(); // Back to session-only echo SessionManager::isRememberMe() ? 'Persistent' : 'Temporary';

:leveloffset!:

<<<

:leveloffset: +1

= API Reference

All methods are static. Call init() first.

== Initialization [cols="2,3a"] |=== | Method | Description | init(array $options = []): void | Start session with config. Idempotent. |===

== Core Storage [cols="2,3a"] |=== | Method | Description | set(string $key, mixed $value): void | Store value; updates activity. | get(string $key, mixed $default = null): mixed | Retrieve value. | has(string $key): bool | Key exists? | delete(string $key): void | Remove key. | all(): array | All namespace data. | clear(): void | Empty current namespace. |===

== Namespacing [cols="2,3a"] |=== | Method | Description | namespace(string $namespace): void | Switch namespace. | currentNamespace(): string | Active namespace. |===

== Flash Messages [cols="2,3a"] |=== | Method | Description | flash(string $key, mixed $value): void | Set for next request. | getFlash(string $key, mixed $default = null): mixed | Get and erase. | hasFlash(string $key): bool | Exists? (non-destructive). |===

== Security & Lifecycle [cols="2,3a"] |=== | Method | Description | regenerate(bool $deleteOld = true): void | New ID; updates activity. | setRegenerateInterval(int $seconds): void | Interval (min 60s). | setTimeout(int $seconds): void | Inactivity timeout (min 1s). | destroy(): void | Full logout (clears data/cookie). | id(): string | Raw session ID. |===

== Remember Me [cols="2,3a"] |=== | Method | Description | enableRememberMe(int $lifetime = 2592000): void | Enable persistent (regenerates ID). | disableRememberMe(): void | Disable (session-only). | isRememberMe(): bool | Currently persistent? |===

:leveloffset!:

<<<

:leveloffset: +1

= Examples

== Login with Remember Me [source,php]

SessionManager::init(['remember_me' => $_POST['remember'] ?? false]);

if (authenticate($_POST['email'], $_POST['password'])) { SessionManager::set('user_id', $user->id); SessionManager::enableRememberMe(); // If checkbox checked SessionManager::flash('success', 'Welcome!'); header('Location: /dashboard'); } else { SessionManager::flash('error', 'Invalid credentials'); }

== Namespaced E-Commerce [source,php]

UserSession::set('logged_in', true); CartSession::set('total', 99.99); echo CartSession::all(); // ['total' => 99.99] SessionManager::namespace('user'); // Switch back

:leveloffset!:

<<<

:leveloffset: +1

= Security Considerations

:leveloffset!:


All versions of session with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
inanepain/stdlib Version *
inanepain/datetime Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package inanepain/session contains the following files

Loading the files please wait ...