locosoftworks/php-cookie-session

Session save handler used to store the session in a cookie

dev-master 2014-07-10 00:28 UTC

This package is not auto-updated.

Last update: 2024-04-27 14:17:23 UTC


README

Requires

  • PHP >= 5.3

Composer Install

"minimum-stability": "dev",
"require": {
    "locosoftworks/php-cookie-session": "dev-master"
}

Usage

$handler = new Loco\Session\SaveHandler\ClientSession();

It is recommended that you encrypt the session. Create a class that implements Loco\Crypt\CipherInterface and inject it into the session handler

$handler->setCipher($myEncryptionClass);

Set the session save handler using session_set_save_handler() (see php documentation)

session_set_save_handler(
    array($handler, 'open'),
    array($handler, 'close'),
    array($handler, 'read'),
    array($handler, 'write'),
    array($handler, 'destroy'),
    array($handler, 'gc')
);

session_start();

You MUST call session_write_close BEFORE returning any output. Output Buffering is recommended.