PHP Classes

Session 7: Store session data in files, PDO, cookie, etc.

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 215 All time: 8,323 This week: 455Up
Version License PHP version Categories
sessionhandlers 1.0.0BSD License7HTTP, Databases, Files and Folders, U..., P...
Description 

Author

This package can store session data in files, PDO, cookie, etc..

It can register a session handler that can store and retrieve session data in several types of containers.

Currently it provides drivers that can store data in databases using PDO, Redis, Memcached, files and cookies.

Picture of chrys ugwu
  Performance   Level  
Name: chrys ugwu <contact>
Classes: 16 packages by
Country: Nigeria Nigeria
Age: 31
All time rank: 16807 in Nigeria Nigeria
Week rank: 193 Up8 in Nigeria Nigeria Down
Innovation award
Innovation award
Nominee: 4x

Documentation

Session PHP(7+)

PHP Session Manager (non-blocking, flash, segment, session encryption). Uses PHP open_ssl for optional encrypt/decryption of session data.

Driver support Scope

file&nbsp;&nbsp;&nbsp;cookie&nbsp;&nbsp;&nbsp;pdo&nbsp;&nbsp;&nbsp;memcached&nbsp;&nbsp;&nbsp;redis&nbsp;&nbsp;&nbsp;[license]()&nbsp;&nbsp;&nbsp;Minimum PHP Version

Installation

You can download the Latest release version as a standalone, alternatively you can use Composer

$ composer require ghostff/session
"require": {
    "ghostff/session": "^1.0"
}

Basic usage:

Registering Error Handler (optional)

#This method must be implemented before Session::start
Session::registerErrorHandler(function($error, $error_code)
{
    #Debug::Log($error);
});

Setting or getting session id :void

#When setting ID, method must be implemented before Session::start
Session::id(bin2hex(random_bytes(32)));

#Get ID
echo Session::id();

Initializing Session

$session = Session::start($optional_session_namespace);

Using Segment :Segment

 $segment = $session->segment($required_segment_name);

Setting Session Data

$session->name = 'foo';
# Setting Segment
$segment->name = 'bar';

# Setting Flash
$session->flash->name = 'foobar';
# Setting Segment Flash
$segment->flash->name = 'barfoo';

$session->commit();

Retrieving Session Data

echo $session->name; # outputs foo
# Retrieving Segment
echo $segment->name; # outputs bar

# Retrieving Flash
echo $session->flash->name; # outputs foobar
# Retrieving Segment Flash
echo $segment->flash->name; # outputs barfoo

Removing Session Data

$session->remove->name;
# Removing Segment
$segment->remove->name;

# Removing Flash
$session->remove->flash->name;
# Removing Segment Flash
$segment->remove->flash->name;

Retrieve all session or segment data :array

$session->all($optional_segment);

Check if variable exist in current session namespace :bool

$session->exist($variable_name, $option_segment, $in_flash);

Removing active session or segment data :void

$session->clear($optional_segment);

Destroying session :void

$session->destroy();

Regenerate session ID :void

$session->rotate($keep_old_session_data);

  Files folder image Files (13)  
File Role Description
Files folder imagesrc (1 file, 1 directory)
Plain text file composer.json Data Auxiliary data
Plain text file LICENSE Lic. License text
Plain text file README.md Doc. Documentation

  Files folder image Files (13)  /  src  
File Role Description
Files folder imageSession (3 files, 6 directories)
  Plain text file Session.php Class Class source

  Files folder image Files (13)  /  src  /  Session  
File Role Description
Files folder imageCookie (1 file)
Files folder imageFile (1 file)
Files folder imageMemcached (1 file)
Files folder imagePdo (1 file)
Files folder imageRedis (1 file)
Files folder imagetmp (1 file)
  Plain text file config.php Aux. Auxiliary script
  Plain text file Save.php Class Class source
  Plain text file Segment.php Class Class source

  Files folder image Files (13)  /  src  /  Session  /  Cookie  
File Role Description
  Plain text file Handler.php Class Class source

  Files folder image Files (13)  /  src  /  Session  /  File  
File Role Description
  Plain text file Handler.php Class Class source

  Files folder image Files (13)  /  src  /  Session  /  Memcached  
File Role Description
  Plain text file Handler.php Class Class source

  Files folder image Files (13)  /  src  /  Session  /  Pdo  
File Role Description
  Plain text file Handler.php Class Class source

  Files folder image Files (13)  /  src  /  Session  /  Redis  
File Role Description
  Plain text file Handler.php Class Class source

  Files folder image Files (13)  /  src  /  Session  /  tmp  
File Role Description
  Plain text file sess_gor23cvvn2qmksags74mpurhnq Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:215
This week:0
All time:8,323
This week:455Up
User Comments (1)
I like the package, thank you.
7 years ago (goodbee)
62%StarStarStarStar