PHP Classes

PHP Cookie Session Manager: Store and retrieve data in cookies or PHP sessions

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: 548 This week: 1All time: 5,529 This week: 45Up
Version License PHP version Categories
cookie-session 1.0.8GNU General Publi...7.0HTTP, User Management, PHP 7
Description 

Author

This package can store and retrieve data in cookies or PHP sessions.

It can set session values assigning individual variables or set several values using an associative array.

It can also check if a variable exists, retrieve or delete it is value.

Session data can be stored in PHP sessions or cookie values.

Picture of Pierre-Henry Soria
  Performance   Level  
Name: Pierre-Henry Soria <contact>
Classes: 49 packages by
Country: United Kingdom
Innovation award
Innovation award
Nominee: 18x

Winner: 3x

Documentation

CookieSession

CookieSession is a very light library to manage easily and simply the Session and Cookie with PHP 7+ (and without spending time by configuring and securing them).

Composer Installation

You can add it easily in your projec by using Composer.

$ composer require ph-7/cookiesession

Then, include Composer's autoload

require_once 'vendor/autoload.php';

Manual Installation

If you don't use Composer, you can install it without Composer by including the following

require 'src/autoloader.php';

Usage for Session

<?php
use PH7\CookieSession\Session\Session;

$oSession = new Session;

$oSession->set('lang_pref', 'English');

// Create some sessions with an array
$aData = [
    'my_session' => 'The value',
    'another_session' => 'Another value',
    'my_name' => 'Pierre-Henry'
];
// Add these sessions
$oSession->set($aData);


// Get session
echo $oSession->get('lang_pref'); // Will display 'English'
echo $oSession->get('another_session'); // Will display 'Another value'

echo ($oSession->exists('my_name')) ? $oSession->get('my_name') : 'Well, well, we dont have a name in the session'; // Will display 'Pierre-Henry'

$oSession->remove('my_name'); // Remove 'my_name' session

echo $oSession->get('my_name'); // Will display nothing (empty string) as 'my_name' session has been removed

Usage with Cookie (very similar)

<?php
use PH7\CookieSession\Cookie\Cookie;

$oCookie = new Cookie;

$oCookie->set('mycookie', 'Amazing Value!');

// Create some cookies in array
$aCookies = [
    'name' => 'Pierre-Henry',
    'city' => 'Manchester',
    'job' => 'Software Engineer'
];
$oCookie->set($aCookies);

if ($oCookie->exists($aCookies)) {
    echo 'All the following cookies exist: ' . implode(', ', $aCookies);
}

echo $oCookie->get('name'); // Will display 'Pierre-Henry'
echo $oCookie->get('mycookie'); // Will display 'Amazing Value!'

$oCookie->remove($aCookies); // Remove all cookies

echo $oCookie->get('name');  // Will display nothing (empty string)

Requirements

  • PHP 7 or higher

The Author

I'm Pierre-Henry Soria, Software Developer passionate about a lot of things and currently living in Manchester city, UK

Contact

You can send an email at pierrehenrysoria [AT] gmail {D0T} COM or at phy {AT} hizup [D0T] UK

License

Under General Public License 3 or later.


  Files folder image Files (12)  
File Role Description
Files folder imagesrc (5 files, 2 directories)
Accessible without login Plain text file .travis Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (12)  /  src  
File Role Description
Files folder imageCookie (2 files)
Files folder imageSession (2 files)
  Accessible without login Plain text file autoloader.php Aux. Auxiliary script
  Plain text file Config.php Class Class source
  Plain text file IConfig.php Class Class source
  Plain text file ICookieSession.php Class Class source
  Plain text file Various.php Class Class source

  Files folder image Files (12)  /  src  /  Cookie  
File Role Description
  Plain text file Config.php Class Class source
  Plain text file Cookie.php Class Class source

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

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:548
This week:1
All time:5,529
This week:45Up