PHP code example of aloframework / session
1. Go to this page and download the library: Download aloframework/session library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aloframework / session example snippets
use AloFramework\Session\RedisSession;
//Make our Redis connection
$redis = new Redis();
$redis->connect('127.0.0.1');
//Start our session. The redis parameter can be omitted, in which case the code above will be run automatically
// within the class
$sess = (new RedisSession($redis))->start();
//That's it - you can now use the handler just like you would use a regular PHP session.
$_SESSION['foo'] = 'bar';
unset($_SESSION['qux']);
echo $_SESSION['baz'];
//Additionally, you can work directly with the RedisSession object via the ArrayAccess interface and magic
// getter+setter:
$sess->foo = 'bar';
$sess['foo'] = 'bar';
unset($sess['foo']);
echo $sess->foo;
echo $_SESSION['foo'];