userfrosting / session
Uniform interface for storing sessions in a variety of mediums, based on illuminate/session
Installs: 47 300
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 7
Forks: 2
Open Issues: 0
Requires
- php: >=7.1
- illuminate/session: ^5.8
- illuminate/support: ^5.8
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.13
- phpunit/phpunit: ^7.5 | ^8.5
README
Branch | Build | Coverage | Style |
---|---|---|---|
master | |||
develop |
Example usage:
use Illuminate\Filesystem\Filesystem;
use Illuminate\Session\FileSessionHandler;
use UserFrosting\Session\Session;
// Use custom filesystem sessions
$fs = new FileSystem;
$handler = new FileSessionHandler($fs, \UserFrosting\APP_DIR . "/sessions");
// Creates a new wrapper for $_SESSION
$session = new Session($handler, $config['session']);
// Starts the session
$session->start();
// Set some values
$session['contacts.housekeeper.name']; = 'Alex "the man" Weissman';
// They're stored in array format...
print_r($session->all());
// Output is:
/*
[
'contacts' => [
'housekeeper' => [
'name' => 'Alex "the man" Weissman'
]
]
];
*/
// Destroy the session, both in memory and on the persistence layer, and tell the browser to remove the cookie
$session->destroy();