2017 © Pedro Peláez
 

library session

Easy to use library for managing PHP built-in sessions

image

delfimov/session

Easy to use library for managing PHP built-in sessions

  • Thursday, February 22, 2018
  • by elfimov
  • Repository
  • 1 Watchers
  • 1 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 15 % Grown

The README.md

License, (*1)

Session

PSR-11 compatible easy to use library for managing PHP built-in sessions. PDO handler included., (*2)

Requirements

How to install

Add this line to your composer.json file:, (*3)

"delfimov/session": "~1.0"

or, (*4)

composer require delfimov/session

How to configure

The session management system supports a number of configuration options which you can place in your php.ini file or redefine in your code., (*5)

The most important settings with recommended values:, (*6)

session.name = PHPSESSID
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 2592000
; lifetime of sessions = 60*60*24*30 = 30 days
session.use_cookies = 1
session.use_only_cookies = 1
session.cookie_lifetime = 2592000
; same as session lifetime

I highly recommend to use https protocol and marks the cookie as accessible only through the HTTP protocol., (*7)

session.cookie_secure = 1
session.cookie_httponly = 1

See PHP Sessions Runtime Configuration for more details., (*8)

An example

See example directory for sources., (*9)

require_once __DIR__ . '/../vendor/autoload.php';
$session = new DElfimov\Session\Session(
    new DElfimov\Session\Handlers\PDOHandler(
            new \PDO('mysql:dbname=testdb;host=127.0.0.1', 'dbuser', 'dbpass')
    )
);

$session->set('a', 'value a');

try {
    echo $session->get('a');
} catch (\Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}

if ($session->has('b')) {
    echo 'Wonder!';
}

$session->remove('a');

TODO

  • Better code coverage
  • Handlers

The Versions

22/02 2018

dev-master

9999999-dev https://github.com/delfimov/Session/

Easy to use library for managing PHP built-in sessions

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Dmitry Elfimov

php pdo mysql sessions psr-11

20/02 2018

v1.0.2

1.0.2.0 https://github.com/delfimov/Session/

Easy to use library for managing PHP built-in sessions

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Dmitry Elfimov

php pdo mysql sessions psr-11

15/02 2018

v1.0.1

1.0.1.0 https://github.com/delfimov/Session/

Easy to use library for managing PHP built-in sessions

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Dmitry Elfimov

php pdo mysql sessions psr-11

15/02 2018

v1.0.0

1.0.0.0 https://github.com/delfimov/Session/

Easy to use library for managing PHP built-in sessions

  Sources   Download

MIT

The Requires

  • php >=7.1

 

The Development Requires

by Dmitry Elfimov

php pdo mysql sessions psr-11