PHP Classes

PHP Cookie Session Handler: Handler class that stores session data in cookies

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2024-07-05 (3 months ago) RSS 2.0 feedNot enough user ratingsTotal: 108 All time: 9,671 This week: 42Up
Version License PHP version Categories
cookiesessionhandler 1.0.1MIT/X Consortium ...7HTTP, Cryptography, User Management, P..., P...
Description 

Author

This package provides a handler class that stores session data in cookies.

It provides a class that has functions that has all functions to load and save session data in cookies.

The session data is stored in cookies by encrypting the data with a private key defined on the server side.

Picture of Ramesh Narayan Jangid
  Performance   Level  
Name: Ramesh Narayan Jangid <contact>
Classes: 9 packages by
Country: India India
Innovation award
Innovation award
Nominee: 4x

Winner: 3x

Documentation

Cookie Session Handler

Handler class that stores session data in cookies

Basics

For web application with high traffic we use different modes to saving session data; example: files and databases.

To manage session of web application with high traffic it becomes difficult with files or a database as a mode to save session data.

This class provides solution to this problem by using COOKIE as a storage media in a safer way with encryption.

To use the encryption we need to follow few steps to create the base64 encoded $key and $iv as below.

$key = openssl_random_pseudo_bytes(32); // 256-bit key
$iv = openssl_random_pseudo_bytes(16); // 128-bit IV

/*
* Store the below base64 encoded key and IV somewhere safe in the code
*/

$key_base64 = base64_encode($key); // <BASE64_KEY>
$iv_base64 = base64_encode($vi);   // <BASE64_IV>

Storing above base64 encoded key and iv in config file

define('BASE64_KEY', '<BASE64_KEY>');
define('BASE64_IV', '<BASE64_IV>');

Instructions to use

Include the below file in scripts to use session

include_once ('CookieSessionHandler.php');
session_start();

> Note: The amount of details that can be stored in session depends on the length of string cookie supports in a browser.


  Files folder image Files (4)  
File Role Description
Accessible without login Plain text file composer.json Data Auxiliary data
Plain text file CookieSessionHandler.php Class Cookie Session Handler
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

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:108
This week:0
All time:9,671
This week:42Up