2017 © Pedro Peláez
 

library session

A simple object-oriented wrapper to PHP's session functions.

image

phputil/session

A simple object-oriented wrapper to PHP's session functions.

  • Tuesday, February 13, 2018
  • by thiagodp
  • Repository
  • 1 Watchers
  • 4 Stars
  • 303 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 5 % Grown

The README.md

Session

PHP's session in a object-oriented version., (*1)

Main files: * Interface phputil\Session * Class phputil\FileBasedSession, (*2)

This project uses semantic versioning., (*3)

Installation

composer require phputil/session

Example 1

Setting and getting a value from the session., (*4)

$session = new phputil\FileBasedSession();
$session->start();

$session->put( 'user_name', $_POST[ 'user_name' ] ); // Set a value in the session
echo 'Hello, ', $session->get( 'user_name' ); // Get a value from the session

Example 2

Setting session cookie name and cookie duration., (*5)

$session = new phputil\FileBasedSession();
$session->setName( 'myapp' ); // (optional) "PHPSESSID" session cookie key becomes "myapp"
$session->setCookieParams( $lastOneDay = 60 * 60 * 24 ); // (optional) cookie will last one day
$session->start();

Example 3

Swapping between sessions., (*6)

$session = new phputil\FileBasedSession();

$session->start();
$savedId = $session->id();
$session->close();

// Opening another session
$session->id( $_GET[ 'another_id' ] );
$session->start(); // starts the session with id "another_id"
...
$session->close();

// Restoring the session with "savedId"
$session->id( $savedId );
$session->start();

Example 4

Regenerating the session id., (*7)

$session = new phputil\FileBasedSession();
$session->start();
$session->regenerateId( true ); // true means delete the old file

Example 5

Destroying the session., (*8)

$session = new phputil\FileBasedSession();
$session->start();
$session->destroy();

The Versions

13/02 2018

dev-master

9999999-dev http://github.com/thiagodp/session

A simple object-oriented wrapper to PHP's session functions.

  Sources   Download

LGPL-3 LGPL-3.0-or-later

The Requires

  • php >=5.2.0

 

php cookie session

05/05 2017

2.1.1

2.1.1.0 http://github.com/thiagodp/session

A simple object-oriented wrapper to PHP's session functions.

  Sources   Download

LGPL-3

The Requires

  • php >=5.2.0

 

php cookie session

04/12 2016

2.1

2.1.0.0 http://github.com/thiagodp/session

A simple object-oriented wrapper to PHP's session functions.

  Sources   Download

LGPL-3

The Requires

  • php >=5.2.0

 

php cookie session

22/04 2016

2.0

2.0.0.0 http://github.com/thiagodp/session

A simple object-oriented wrapper to PHP's session functions.

  Sources   Download

LGPL-3

The Requires

  • php >=5.2.0

 

php cookie session

08/03 2016

1.1

1.1.0.0 http://github.com/thiagodp/session

A simple object-oriented wrapper to PHP's session functions.

  Sources   Download

LGPL-3

The Requires

  • php >=5.2.0

 

php cookie session

23/10 2015

1.0.1

1.0.1.0 http://github.com/thiagodp/session

A simple object-oriented wrapper to PHP's session functions.

  Sources   Download

LGPL-3

The Requires

  • php >=5.2.0

 

php cookie session

22/10 2015

1.0

1.0.0.0 http://github.com/thiagodp/session

A simple object-oriented wrapper to PHP's session functions.

  Sources   Download

LGPL-3

The Requires

  • php >=5.2.0

 

php cookie session