2017 © Pedro Peláez
 

library php-session

A PHP Session Class

image

prog98rammer/php-session

A PHP Session Class

  • Thursday, April 12, 2018
  • by prog98rammer
  • Repository
  • 1 Watchers
  • 7 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

PHP Session Manager

### Allows you to deal with Session in php

Installation

#include your file
include './to/path/session-manager.php';

use Prog98rammer\Session\Session;

// start the session.
$session = new Session();

Usage

-- Basic Usage, (*1)

Set the sessoin prefix

There are two ways to set the prefix

-- First One, (*2)

$session = new Session($prefix);

-- Example, (*3)

$session = new Session('test_');

Second way

$session = new Session;
$session->prefix('test_')->set('name', 'khalid'); // it will set the session as "test_name"

Get the session prefix

$sesssion->getPrefix(); // will return the session prefix

Get all session keys

$sesssion->all();

Add new session

// store the new session
$session->set($key, $value);

// for Example
$session->set('name', 'John');

Add more than one session by Chaining method

$session->set('name', 'Khalid')
        ->set('age', 19)
        ->set('country', 'Iraq')
        ->set('city', 'Baghdad');

Add more than one session by providing an array

$session->set([
    'name' => 'khalid',
    'age' => 19,
    'location' => [
        'country' => 'iraq',
        'city' => 'baghdad'
    ]
]);

Get one session by key

$sesssion->get($key); // will use the default prefix.

Get All Session by spicefic prefix

$session->fromPrefix($prefix);

#example
$session->fromPrefix('test'); // returns an array of all session that have a "test" prefix

Check if the session exists!


Session::has($key); // returns True or False #example if(Session::has('is_loggin')) { // do something } else { // do something else }

Remove Session by key

$sesssion->remove($key);

by chaining method

$session->remove('name')
        ->remove('age')
        ->remove('location');

by providing an array of keys

$session->remove([
    'name', 'age', 'location'
]);

or just like this

$session->remove('name', 'age', 'location');

Get the session id

$sesssion->id(); // will return the id of the session.

Regenerate the session id

$sesssion->regenerate_id(); // will return the id of the session.

if you like to remove all session at one

$session->destroy();

The Versions

12/04 2018

dev-master

9999999-dev

A PHP Session Class

  Sources   Download

MIT

by Khalid M. Sheet

03/04 2018

1.0

1.0.0.0

A PHP Session Class

  Sources   Download

MIT

by Khalid M. Sheet