Skip to content

PHP's native session wrapper with namespacing

Notifications You must be signed in to change notification settings

okneloper/session

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

PHP's native session wrapper with namespacing

<?php

use Okneloper\Session\Session;

// optional
Session::setDefaultNamespace('My Namespace');

// Start the session if necessay and Iniitialize a session object
$session = Session::newInstance();

$session->username = 'admin';
$session->foo = array('bar', 'baz');

print_r($_SESSION);
Array
(
    [My Namespace] => Array
        (
            [username] => admin
            [foo] => Array
                (
                    [0] => bar
                    [1] => baz
                )

        )

)
$session1 = Session::newInstance('admin');

$session1->username = 'johndoe';
$session1->role = 'manager';

$session2 = Session::newInstance('profile');

$session2->username = 'the_master';
$session2->timestamp = time();

print_r($_SESSION);
Array
(
    [admin] => Array
        (
            [username] => johndoe
            [role] => manager
        )

    [profile] => Array
        (
            [username] => the_master
            [timestamp] => 1455371559
        )

)

About

PHP's native session wrapper with namespacing

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages