toropyga/session

Libraries for working with sessions from Toropyga

Maintainers

Package info

github.com/Toropyga/Session

pkg:composer/toropyga/session

Transparency log

Statistics

Installs: 258

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v3.0.2 2026-07-29 10:48 UTC

This package is auto-updated.

Last update: 2026-08-29 11:02:30 UTC


README

A library for working with sessions in PHP

License Version PHP

Table of Contents

Overview

The Session class is a library for working with sessions in PHP. It requires PHP version 5 or higher. It can store user session data in a database. It works with MySQL and PostgreSQL databases. It automatically creates a table in the database, if one does not already exist, to store session data.

Installation

The recommended way to install the Session library is using Composer:

composer require toropyga/session

Configuration

Default parameters can be pre-configured either directly in the class itself, or by using named constants. Named constants, if needed, should be defined before the class is called — for example, in a configuration file — and they determine the default settings.

  • SE_LIVETIME - lifetime of a simple (guest) session, in seconds
  • SE_LIVETIME_REM - lifetime of a saved (remembered) session, in seconds
  • SE_NAME - session name
  • SE_USEDB - whether to use a database (true|false)
  • SE_SECURE - the "secure" security parameter for the COOKIE (true|false)
  • SE_HTTPONLY - the "httponly" security parameter for the COOKIE (true|false)
  • SE_SAMESITE - cross-domain cookie transfer policy (lax|strict|none)
  • SE_USE_TMPL - create a dedicated directory (folder) for storing session files (true|false)
  • SE_TMPL_NAME - name of the directory used to store sessions
  • SE_USE_SERVER_NAME - use the server name when creating the directory (true|false)
  • SE_USE_SDIR - use the standard folder for storing sessions (true|false)
  • SE_LOG_NAME - name of the file the log is saved to
  • SE_DEBUG - enable or disable debugging and logging

Getting started

require_once("vendor/autoload.php");

Initialize the class

$SE = new Toropyga\Session();

Usage example

$SE = new Toropyga\Session();
$SE->setDebug(true); // enable debugging
$SE->sessionInit();